Qt, multiple inheritance: QApplication and new-style class not possible

Sibylle Koczian Sibylle.Koczian at Bibliothek.Uni-Augsburg.de
Wed May 12 07:01:54 EDT 2004


I want to try out several applications, all doing the same thing but 
using different GUI libraries (Tkinter, Qt, wxWindows). Using an example 
I found in a book I wrote a class containing the GUI independent methods 
of the application, let's call it MyAppClass. The book is written before 
Python 2.2, so it uses classic classes, but I want some properties, so I 
made MyAppClass a new style class.

For the Tkinter GUI I derive another class, TkAppClass, from this, whose 
methods use Tkinter. As Qt applications need an application class 
derived from QApplication, I wanted to derive my QAppClass from both 
classes, QApplication and MyAppClass, but got a TypeError: "cannot 
create a class derived from a SIP generated class (QApplication) and a 
new-style class - use SIP v4 or later instead".

Now I see three different ways out of this:

a) use SIP v4, but it's pre-release. Moreover I'm just starting with 
Linux anyway, so I'd like to keep to ready-made rpm packages for my 
distribution (SuSE 9.1) and I can't find any.

b) make MyAppClass a classic class.

c) instead of deriving my QAppClass from QApplication and from 
MyAppClass, derive it only from QApplication and put a reference to a 
MyAppClass instance into it as an attribute.

What's the best way (and why), or is there a d)?

Thank you,
Koczian

-- 
Dr. Sibylle Koczian
Universitaetsbibliothek, Abt. Naturwiss.
D-86135 Augsburg

Tel.: (0821) 598-2400, Fax : (0821) 598-2410
e-mail : Sibylle.Koczian at Bibliothek.Uni-Augsburg.DE




More information about the Python-list mailing list