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

Andre Somers andre at familiesomers.nl
Mon Aug 22 07:54:41 CEST 2011


Op 20-8-2011 14:06, Constantin Makshin schreef:
> 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.
Your explanation on how the issue arises is quite clear, thank you. But 
how does that disqualify it as a bug?

A QDoubleSpinBox is, from the programmers and users point of view, one 
single element that you can interact with. Nobody cares that internally 
it uses a QLineEdit and that QLineEdit resets its undo buffer as soon as 
you call setText on it. The programmer did not call setText on the 
QDoubleSpinBox, and thus he expects the the undo feature to Just 
Work(TM). IMHO, the problem is that the undo buffer of the QLineEdit is 
used at all. QDoubleSpinBox needs its own undo buffer that _does_ allow 
the user to undo and redo properly, no matter what kind of formatting 
fixes were applied to the number entered in the line edit part of the 
spin box.

André


> 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?
>>
>>
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at qt.nokia.com
>> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
||||||||
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110822/7c704bc8/attachment.html 


More information about the Qt-interest-old mailing list