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 413 - Base class not correctly detected for a class derived from QtGui.QWidget
: Base class not correctly detected for a class derived from QtGui.QWidget
Status: CLOSED WONTFIX
Product: PySide
Classification: Unclassified
Component: PySide
: 0.4.2
: All All
: P3 normal
Assigned To: renato filho
:
:
:
  Show dependency treegraph
 
Reported: 2010-10-14 10:06 EEST by Matti Airas
Modified: 2010-11-25 17:53 EET (History)
8 users (show)

See Also:


Attachments
The complete failing example (20.52 KB, application/x-bzip)
2010-10-14 10:06 EEST, Matti Airas
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matti Airas 2010-10-14 10:06:21 EEST
Created attachment 116 [details]
The complete failing example

When porting PyQt's anomation/easing example, I get following:

Traceback (most recent call last):
  File "./easing.py", line 216, in <module>
    w = Window()
  File "./easing.py", line 71, in __init__
    super(QtGui.QWidget, self).__init__(parent)
TypeError: PySide.QtCore.QObject isn't a direct base class of Window

even though the code clearly states:

class Window(QtGui.QWidget):
    def __init__(self, parent=None):
        super(QtGui.QWidget, self).__init__(parent)
        [...]

The complete example is attached.
Comment 1 Hugo Parente Lima 2010-10-18 15:46:23 EEST
You need to use the super passing the type of the current class, not the base
class, otherwise python will not initialize the QWidget, only QObject, so the
correct code is:


class Window(QtGui.QWidget):
    def __init__(self, parent=None):
        super(Window, self).__init__(parent)
        [...]

If we consider the code calling QObject constructor and not the QWidget
constructor valid, a lot of things will be wrong due to QWidget not being
initialized, e.g.:

class Bar(object):
    def __init__(self):
        print "Bar"

class Foo(Bar):
    def __init__(self):
        Bar.__init__(self)
        print "Foo"
        self.a = 5

class Window(Foo):
    def __init__(self):
        super(Foo, self).__init__()
        pass

w = Window()
# "a" member variable will not be initialized.
print w.a
Comment 2 Matti Airas 2010-10-21 05:19:13 EEST
Yep, my bad - didn't notice the incorrect type in the super call. I added a
notice about this to the Wiki:

http://developer.qt.nokia.com/wiki/Differences_Between_PySide_and_PyQt
Comment 3 Hugo Parente Lima 2010-11-25 17:53:39 EET
Released on version 1.0.0~beta1