[PyQt] Multiple Inheritance

Arnold Krille arnold at arnoldarts.de
Wed Apr 20 14:28:20 BST 2011


On Wednesday 20 April 2011 13:01:57 Zoltan Szalai wrote:
> Hi All,
> 
> The PyQt Reference Guide says:
> "It is not possible to define a new Python class that sub-classes from
> more than one Qt class."
> [
> http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/gotchas.html#mul
> tiple-inheritance ]
> 
> The code attached works here until you remove the comment before the
> last line. Then it raises a TypeError.
> I should really use something like this in a PyQt app (if it's not a
> very bad idea anyway) and I wonder what are the limitations here or what
> are the best practices to solve this kind of problem (if there are any).

(I haven't looked at your code.)

The limitation doesn't come from python or PyQt. Its purely because of Qt and 
means that you can not inherit from multiple classes that are or inherit from 
QObject. And its the same for all class-trees I believe. Unless you use 
virtual inheritance in C++, but last time I tried (some years back) that led 
to strange errors and was neither encouraged nor supported in any point in Qt.

Have fun,

Arnold
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110420/eb273bfe/attachment.pgp>


More information about the PyQt mailing list