I think the Qt on your platform is either too old or otherwise broken. It works fine on OS X, on both Qt 4.8.5 and Qt 5.2.0.
There are two other solutions:
If you don't care about full range of unsigned integer, simply use
QSpinBox
and set non-negative minimum and maximum. That's all. On platforms with 32 bit int, maximumint
value is 2^31-1, that's about half of the maximumuint
value of 2^32-1.You can use
QDoubleSpinBox
. On sane platforms you care about, double has more than 32 bits of mantissa, so you can convert it to aquint32
without loss of precision.If you want to be sure, just add
static_assert(sizeof(double)>4)
anywhere in your code.If one worries about performance, then it really doesn't matter. The calculations are performed at the rate of user input events: that's a couple dozen double operations per second. It doesn't matter.