Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set string to QDoubleSpinBox

Tags:

c++

qt

qspinbox

Regarding some task I must do the following. Consider I have a QDoubleSpinBox with positive values from 0 to 1000. And every time when user tries to lower the value of spinbox, f.e. to click the down button when value is 0, the value of spinbox must be string "unset". I tried to do this, to clear the value of spinbox and then setPrefix. But it did not worked. Any other solutions?

like image 758
Eduard Rostomyan Avatar asked Nov 14 '14 08:11

Eduard Rostomyan


Video Answer


1 Answers

You can try specialValueText.

This is a example:

#include <QApplication>
#include <QDoubleSpinBox>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QDoubleSpinBox doubleSpinBox;
    doubleSpinBox.setRange(0.f, 1000.f);
    doubleSpinBox.setValue(1.f);
    doubleSpinBox.setSpecialValueText("unset");

    doubleSpinBox.show();
    return a.exec();
}

when value is 0, the value of spinbox must be string "unset".

like image 199
pezy Avatar answered Oct 06 '22 01:10

pezy