[Qt-interest] QSpinBox with large values

Robert Hairgrove evorgriahr at hispeed.ch
Mon Feb 2 18:25:55 CET 2009


Милош Тошић wrote:
> Hi,
> 
> Could anyone explain me why the setRange / setMinimum / setMaximum 
> methods of QSpinBox are taking ints for arguments?
> My problem is that I would like to have 64bit values editable with spin 
> box but for this to work those methods would have to take QVariant as an 
> argument.
> I see that all those functions will convert ints to variants so why not 
> pass them directly?
> 
> Also, any advice for bypassing this problem is appreciated!
> 
> Thanks!
> 

If you are using suitably large increments, you could simply scale the 
integer values appropriately. QDoubleSpinBox handles floating point 
values which can be in the range of 64-bit integers, but with the 
accompanying rounding issues inherent with all floating point numbers.

Or you could create a custom class which inherits from QAbstractSpinBox 
... look at the source code for QDateTimeEdit to see how it is done.

It is a very straightforward method to make, e.g., a spin box with 
alphabetic characters instead of integers, etc. I'm sure it could be 
done for 64-bit values.



More information about the Qt-interest-old mailing list