[PySide] Correction: TypeError setting multiple inheritance instance as QWidget parent
Owen Kelly
owensother at sympatico.ca
Wed Oct 10 20:09:04 CEST 2012
My first email had inaccurate code.
The revised code shows Foo subclass initializations.
The TypeError is still present with this code.
import sip
sip.setapi('QString', 2)
sip.setapi('QUrl', 2)
from PySide import QtGui
class Node(object):
def __init__(self, str):
pass
class Foo(QtGui.QTabWidget, Node):
def __init__(self):
super(Foo, self).__init__(parent=None) # should call
QtGui.QTabWidget.__init__(self, parent=None)
Node.__init__(self,'Node name is Disp')
self.bar = Bar(self) # Can I fix a TypeError here by giving a
different argument to Bar?
class Bar(QtGui.QDialog):
def __init__(self, parent_widget):
super(Bar, self).__init__(parent=parent_widget) # <<<<<<<<==========
TypeError occurs here
#QtGui.QDialog.__init__(self, parent=parent_widget) # using this
line instead of line above gives same error
From: Owen Kelly [mailto:oekelly at ieee.org]
Sent: October-10-12 1:08 PM
To: 'pyside at qt-project.org'
Subject: TypeError setting multiple inheritance instance as QWidget parent
Hello all,
I am migrating from PyQt to PySide; the PyQt code works.
I am trying to resolve a multiple inheritance issue.
The problem seems to be that PySide.QDialog.__init__ does not recognize an
instance of Foo as a possible parent.
unhandled TypeError
QDialog(QWidget parent=None,Qt.WindowFlags flags=0): argument 'parent' has
unexpected type 'Foo'
However, Foo is subclassed from QWidget but also from another class, Node.
Simplified code:
import sip
sip.setapi('QString', 2)
sip.setapi('QUrl', 2)
from PySide import QtGui
class Node(object):
pass
class Foo(QtGui.QTabWidget, Node):
def __init__(self):
self.bar = Bar(self) # Can I fix this by giving a different argument to
Bar?
class Bar(QtGui.QDialog):
def __init__(self, parent_widget):
super(Bar, self).__init__(parent=parent_widget) # <<<<<<<<==========
TypeError occurs here
#QtGui.QDialog.__init__(self, parent=parent_widget) # using this
line instead of line above gives same error
Is the solution here that I should use composition instead of inheritance?
A related question may be this
http://stackoverflow.com/questions/8335930/python-how-to-get-the-base-instan
ce-of-an-instance
Python 2.6.6, Win32, PySide 1.1.1
If multiple inheritance is not possible, maybe
qt-project.org/wiki/Differences_Between_PySide_and_PyQt
could be updated.
Thanks for your suggestions.
Owen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20121010/9854f532/attachment.html>
More information about the PySide
mailing list