PDA

View Full Version : multiinherit trouble? ....template QList



bigbigmoon
27th October 2006, 03:21
hello every,
I hope that A inherit from QListBox and QPopupMenu ,but there 's something wrong with it :

souce code :


class spinxList :public QListBox ,public QPopupMenu
{
Q_OBJECT public :
..........
}

error :
'QObject ' is an ambiguous base of 'spinxList ',
what can i do to solve this problem ?

another problem :
I learn about that QList is a template class ,it 's items can be of any type .
but I could't find the class QList from QT referrence document ,
is there the template class ?

thank you for your reply !

munna
27th October 2006, 05:27
I learn about that QList is a template class ,it 's items can be of any type .
but I could't find the class QList from QT referrence document ,
is there the template class ?

In Qt3 its called QPtrList (pointer based) and QValueList (value based).

bigbigmoon
27th October 2006, 07:55
Thank you for your rapid reply!:)

jpn
27th October 2006, 08:48
I hope that A inherit from QListBox and QPopupMenu ,but there 's something wrong with it :

souce code :

class spinxList :public QListBox ,public QPopupMenu
{
Q_OBJECT public :
..........
}

error :
'QObject ' is an ambiguous base of 'spinxList ',
what can i do to solve this problem ?

Both base classes, QListBox and QPopupMenu are QObjects. Multiple inheritance of QObject is not supported.

As Volker from Trolltech has said (http://lists.trolltech.com/qt-interest/2004-07/thread00688-0.html):

Some of the QObject concepts, i.e. parent/child ownership, don't make a
whole lot of sense in a multi-inheritance class hierarchy. Hence this is
not supported (technically it is a documented limitation of the meta
object system).

bigbigmoon
30th October 2006, 00:45
Thank you for your reply;)