[Qt-interest] Mismatch between QSpinBox::textFromValue() documentation and actual behavior

Anders Bakken anders.bakken at nokia.com
Wed Mar 24 16:08:35 CET 2010


On Wed, Mar 24, 2010 at 03:33:59AM +0100, ext K. Frank wrote:
> Anders -
> 
> Thanks for the explanation.
> 
> On Tue, Mar 23, 2010 at 9:06 PM, Anders Bakken <anders.bakken at nokia.com> wrote:
> > On Wed, Mar 24, 2010 at 01:41:48AM +0100, ext K. Frank wrote:
> >> ...
> >> I find that the behavior of QSpinBox::textFromValue() does not match
> >> the documentation.
> >> ...
> > This is missing from the docs. It does indeed remove it. While this may
> > or may not be the most appropriate default it's relatively easy to work
> > around.
> 
> I think the appropriate default is the current behavior of not having the
> thousands separators.  (It would, however, be convenient to be able to
> turn on the thousands separators with an option flag.)
> 
> Just to make sure I understand, is the suggested work-around to derive from
> QSpinBox and override textFromValue() (as in the MySpinBox class, below)?

Yeah. It seems like that is all it takes.

> Just to clarify, my purpose in having the getBaseTextFromValue() function was
> to access specifically the base-class (QSpinBox) version of textFromValue,
> which, as a protected member, cannot be called from outside of a derived class.
> That is, I am using getBaseTextFromValue() to probe the protected function
> QSpinBox::textFromValue() and verify that it does, indeed, remove the thousands
> separators.

Ah ok. I thought something was a little odd about the expectations there
:-) I guess I just misunderstoo.
> 
> Just to check:  Is the most economical work-around to put in the thousands
> separators to override textFromValue() in a derived class?

Yeah. That's the simplest way. The interpreting functions
(validate/valueFromText) already account for thousand separators.

regards

-- 
Qt Development Frameworks, Nokia, http://qt.nokia.com
Anders Bakken



More information about the Qt-interest-old mailing list