[PySide] TypeError setting multiple inheritance instance as QWidget parent

Owen Kelly owensother at sympatico.ca
Wed Oct 10 19:07:53 CEST 2012


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/9847ba7c/attachment.html>


More information about the PySide mailing list