PDA

View Full Version : QDoubleSpinbox decimal issues.



MartinGFA
20th September 2019, 14:35
Hey people.
I'm trying to put decimals in a QDoubleSpinbox in run-time and it won't work. Should i maybe use an other widget?
What would be nice was if you could write the decimal point manually, but i don't know if there's any functionality for that.
Anybody have any answers?
the code i have at the moment in QDoubleSpinboxes (they're all in a vector to quickly set their values)

for(auto object : transformSpinBoxes)
{
object->setMaximumWidth(spinBoxWidthMax);
object->setMinimumWidth(spinBoxWidthMin);
object->setMaximum(10000);
object->setMinimum(-10000);
object->setButtonSymbols(QAbstractSpinBox::NoButtons);
object->setSingleStep(0);
object->setDecimals(3);
// object->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
}

d_stranz
20th September 2019, 16:21
So according to your code, you are configuring your spin boxes so they can't actually be used as spin boxes. You set the single step to 0 (which effectively disables the up / down arrow keys) and you disable the buttons. Why? The only thing the user can do with these is to type a value into them. If you don't want them to function as spin boxes, then use a QLineEdit with a QDoubleValidator.