[Qt-interest] Derive slots from non-Qt-based classes

Dan White ygor at comcast.net
Tue Apr 28 18:25:44 CEST 2009


QGLWidget is a QWidget.  It should work.

<http://doc.trolltech.com/4.5/qglwidget.html>

There is an example on the doc page

“Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.”
Bill Waterson (Calvin & Hobbes)

----- Original Message -----
From: Stefan Bisplinghoff <bisplinghoff at hia.rwth-aachen.de>
To: qt-interest at trolltech.com
Sent: Tue, 28 Apr 2009 15:43:36 +0000 (UTC)
Subject: Re: [Qt-interest] Derive slots from non-Qt-based classes

Ian Thomson schrieb:
> In the example code you posted, the Q_OBJECT macro is missing.

Hmm.. yes, it's missing in SomeDerivedClass.
Q_OBJECT in SomeBaseClass is not allowed as it doesn't inherit from
QObject. And I really don't want to inherit from QObject! :-)

To make things more clear:
I want to extend QWidget based classes with additional methods.
Implementing the stuff in a subclass derived from QWidget works fine for
QWidgets but using the same additional stuff with a QGLWidget is not
possible.

I understand that I cannot call the slot in SomeBaseClass as this has
not been moc'ed, but I think it may be possible to use the parent code
in SomeDerivedClass, which actually is moc'ed.

Regards,
 Stefan






More information about the Qt-interest-old mailing list