[PyQt] Issue with multiple inheritance
Phil Thompson
phil at riverbankcomputing.com
Fri Jan 20 22:19:15 GMT 2017
On 20 Jan 2017, at 8:43 pm, Dmitry Shachnev <mitya57 at ubuntu.com> wrote:
>
> Hi all,
>
> I am trying to write a class that inherits from two parent classes: one from
> Qt and one mine.
>
> The minimal example is:
>
> -----------------------------------
> from PyQt5.QtCore import QObject
>
> class AnotherBase:
> def __init__(self, foo):
> pass
>
> class MyView(QObject, AnotherBase):
> def __init__(self, foo):
> QObject.__init__(self)
>
> MyView('foo')
> -----------------------------------
>
> When I try to run it (with the latest sip and PyQt releases), I get this:
>
> Traceback (most recent call last):
> File "./test.py", line 11, in <module>
> MyView('foo')
> File "./test.py", line 9, in __init__
> QObject.__init__(self)
> TypeError: __init__() missing 1 required positional argument: 'foo'
>
> Which sounds strange to me. Why should QObject.__init__ take my argument?
>
> This does not happen when I replace QObject with my own another base class.
> This also does not happen if I change the order of inheritance: first
> AnotherBase, then QObject.
>
> Is it my misunderstanding or a bug somewhere? (I hope for the former.)
http://pyqt.sourceforge.net/Docs/PyQt5/multiinheritance.html#support-for-cooperative-multi-inheritance
Phil
More information about the PyQt
mailing list