PySide Bugzilla Closed for New Bugs

PySide is now a Qt Add-on and uses the Qt Project's JIRA Bug Tracker instead of this Bugzilla instance. This Bugzilla is left for reference purposes.

Bug 879 - QDoubleSpinBox: Can't call the parent validate() method from a subclass
: QDoubleSpinBox: Can't call the parent validate() method from a subclass
Status: CLOSED FIXED
Product: PySide
Classification: Unclassified
Component: QtGui
: 1.0.3
: All All
: P3 normal
Assigned To: Hugo Parente Lima
:
:
:
  Show dependency treegraph
 
Reported: 2011-06-09 07:30 EEST by Gerald
Modified: 2011-06-22 20:14 EEST (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gerald 2011-06-09 07:30:06 EEST
Hi,
The following code produces a runtime error.  The code works fine if I use a
regular spinbox so I assume it is a fairly specific problem.

import sys
from PySide import QtGui,QtCore

app = QtGui.QApplication(sys.argv)

class MySpinBox(QtGui.QDoubleSpinBox):

    def validate(self,text,pos):
        return QtGui.QDoubleSpinBox.validate(self,text,pos)

box = MySpinBox()

box.show()

app.exec_()
sys.exit()
Comment 1 Gerald 2011-06-09 10:05:39 EEST
When figuring out a work around for this issue I've noticed an inconsistency. 
My re-implemented validate() function must return a
PySide.QtGui.QValidator.State to work.  However, the existing validate()
function returns a tuple with PySide.QtGui.QValidator.State as the first item. 
This means something like this works:
    def validate(self,text,pos):
        v = QtGui.QDoubleValidator(self.minimum(),
                                   self.maximum(),self.decimals(),self)
        return v.validate(text,pos)[0]
But this does not:
    def validate(self,text,pos):
        v = QtGui.QDoubleValidator(self.minimum(),
                                   self.maximum(),self.decimals(),self)
        return v.validate(text,pos)

As an additional issue the documentation isn't up to date for validators. 
They're apparently returning tuples instead of just the state.  This applies to
the .validate() function of classes like QSpinBox as well.
Comment 2 Gerald 2011-06-09 10:29:25 EEST
I've also just figured out that doing something like:

    def valueFromText(self,value):
        return int(value)

in QDoubleSpinBox will cause PySide to hang forever.  If the function must
return a float then an exception should be raised rather than the infinite loop
that occurs now.
Comment 3 Hugo Parente Lima 2011-06-13 22:19:14 EEST
The run-time error doesn't exists anymore due to the fix of bug 871 but another
error was raised, the call to QDoubleSpinBox.validate appears to do nothing.
Comment 4 Hugo Parente Lima 2011-06-15 21:03:08 EEST
Fixed in commit:

pyside/07229012b7a3cd5f80fb944e7a4437246b65f018
Comment 5 renato filho 2011-06-22 20:14:06 EEST
release 1.0.4