473,466 Members | 1,351 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

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 : Si*************@Bibliothek.Uni-Augsburg.DE

Jul 18 '05 #1
3 3278
Sibylle Koczian <Si*************@Bibliothek.Uni-Augsburg.de> writes:
[...]
a) use SIP v4, but it's pre-release. Moreover I'm just starting with [...]

I'd say the acceptability of this depends on what kinds of people the
program needs to be distributed to -- yourself being a special case of
distributee :-) If I know I'll never distribute something, or won't
for, say, a year or so, I feel few qualms about using new code.
Depends what people have said about the stability of the code, of
course, but I'd be surprised if Phil Thompson's pre-release code was
bug-ridden.

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.
If you want to get into good habits, you could make your own rpm by
copying the spec files from old sip / PyQt packages -- it's not too
hard, I'm told.

Personally, I have slovenly habits and just compile from the original
tarball when it's not on a distro CD or automatically fetch-able with
dependencies (using apt-get, in my case).

b) make MyAppClass a classic class.
A shame to lose properties, assuming you have a good use for them.

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),
c). :-)

or is there a d)?


Surely.
John
Jul 18 '05 #2
On Wednesday 12 May 2004 12:01 pm, Sibylle Koczian wrote:
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)?


I'd recommend a). The only reason SIP v4 is still a pre-release is that I said
that I'd only release the final version when the documentation was complete.
The code itself is stable with no known outstanding issues.

Phil

Jul 18 '05 #3
Phil Thompson schrieb:
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.

I'd recommend a). The only reason SIP v4 is still a pre-release is that I said
that I'd only release the final version when the documentation was complete.
The code itself is stable with no known outstanding issues.

In that case I think I'll try it, thank you!

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

Tel.: (0821) 598-2400, Fax : (0821) 598-2410
e-mail : Si*************@Bibliothek.Uni-Augsburg.DE

Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Morgan Cheng | last post by:
It seems no pattern defined by GoF takes advantage of multiple inheritance. I am wondering if there is a situation where multiple inheritance is a necessary solution. When coding in C++, should...
30
by: Vla | last post by:
why did the designers of c++ think it would be more useful than it turned out to be?
20
by: km | last post by:
Hi all, In the following code why am i not able to access class A's object attribute - 'a' ? I wishto extent class D with all the attributes of its base classes. how do i do that ? thanks in...
22
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete...
29
by: MAHESH MANDHARE | last post by:
Hi , Can Anyone explain me exactly why multiple inheritance not used in java and c# thanks, Mahesh -- Have A Good Day, Mahesh, Maheshmandhare@yahoo.co.in
0
by: blackdevil1979 | last post by:
Hello, > "In COM, multiple inheritance between interfaces is not supported. However, by using the derived members capability, multiple inheritance can be simulated."..MSDN Library I have...
60
by: Shawnk | last post by:
Some Sr. colleges and I have had an on going discussion relative to when and if C# will ever support 'true' multiple inheritance. Relevant to this, I wanted to query the C# community (the...
15
by: boris.smirnov | last post by:
Hi all, I have a python script that works without any problem on Windows but with error: QPaintDevice: Must construct a QApplication before a QPaintDevice on Linux. Where could be the...
47
by: Larry Smith | last post by:
I just read a blurb in MSDN under the C++ "ref" keyword which states that: "Under the CLR object model, only public single inheritance is supported". Does this mean that no .NET class can ever...
3
by: johanatan | last post by:
When I first heard about these new features, I was very excited as it would have (if implemented as I had expected) rendered mimicking multiple inheritance almost painless in C#. Unfortunately,...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.