Add option to show description as tooltip

This commit is contained in:
WarmUpTill
2023-05-19 21:52:59 +02:00
committed by WarmUpTill
parent 8d18bb363a
commit 4315d309f2
2 changed files with 12 additions and 5 deletions

View File

@@ -4,7 +4,8 @@
namespace advss {
SliderSpinBox::SliderSpinBox(double min, double max, const QString &label,
const QString &description, QWidget *parent)
const QString &description,
bool descriptionAsTooltip, QWidget *parent)
: QWidget(parent),
_spinBox(new VariableDoubleSpinBox()),
_slider(new QSlider())
@@ -23,8 +24,8 @@ SliderSpinBox::SliderSpinBox(double min, double max, const QString &label,
this,
SLOT(SpinBoxValueChanged(const NumberVariable<double> &)));
QVBoxLayout *mainLayout = new QVBoxLayout();
QHBoxLayout *sliderLayout = new QHBoxLayout();
auto mainLayout = new QVBoxLayout();
auto sliderLayout = new QHBoxLayout();
if (!label.isEmpty()) {
sliderLayout->addWidget(new QLabel(label));
}
@@ -32,7 +33,11 @@ SliderSpinBox::SliderSpinBox(double min, double max, const QString &label,
sliderLayout->addWidget(_slider);
mainLayout->addLayout(sliderLayout);
if (!description.isEmpty()) {
mainLayout->addWidget(new QLabel(description));
if (descriptionAsTooltip) {
setToolTip(description);
} else {
mainLayout->addWidget(new QLabel(description));
}
}
mainLayout->setContentsMargins(0, 0, 0, 0);
setLayout(mainLayout);

View File

@@ -14,7 +14,9 @@ class SliderSpinBox : public QWidget {
public:
SliderSpinBox(double min = 0., double max = 1.,
const QString &label = "threshold",
const QString &description = "", QWidget *parent = 0);
const QString &description = "",
bool descriptionAsTooltip = false,
QWidget *parent = nullptr);
void SetDoubleValue(double);
void SetDoubleValue(const NumberVariable<double> &);
public slots: