[Qt-interest] QDoubleSpinBox can't undo change after losing focus, is this a bug?

Constantin Makshin cmakshin at gmail.com
Sat Aug 20 14:06:39 CEST 2011


No, this is not a bug — if the entered value doesn't contain all required components (not enough digits before/after the decimal separator or lack of the separator itself), QDoubleSpinBox calls the setText() function of its edit field to "fix" the value, clearing this field's undo buffer.

As a proof you may try this (by default, QDoubleSpinBox expects two digits after the decimal separator):
1) focus → enter an integer number or a floating point number with 1 digit in the fractional part → "unfocus" — the spin box changes its contents and you won't be able to undo your changes;
2) focus → enter a floating point number with 2 digits in the fractional part → "unfocus" — format of the entered value is correct, the spin box stays intact and you can undo your changes.

On Saturday, August 20, 2011 06:39:44 AM liang jian wrote:
>     To produce this problem, open Qt Designer, create a widget and
> drag a spin box and a double spin box to this widget. Press Ctrl+R to
> preview it, change the text in the spin box to a different value and
> then click the double spin box, change its value too, return to the
> spin box and right click to show the context menu, you will see undo
> menu item is enabled, but if you go back to the double spin box and
> right click to show the context menu you will see that the undo menu
> item is grayed (I think at that time it should be enabled).  I can
> produce this problem in both my windows 7 and ubuntu 11.04 system, is
> this a bug or a feature?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110820/2deb1393/attachment.bin 


More information about the Qt-interest-old mailing list