[Qt-interest] Making a template class a Q_OBJECT
Malyushytsky, Alex
alex at wai.com
Wed Dec 16 01:16:40 CET 2009
Discussed number of times on the list.
One of the useful link:
http://doc.trolltech.com/qq/qq15-academic.html
It is a good idea to google for 'Q_OBJECT template' before posting.
Regards,
Alex
-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of John Clayton
Sent: Tuesday, December 15, 2009 3:10 PM
To: qt-interest
Subject: [Qt-interest] Making a template class a Q_OBJECT
Hi All
I'm wondering how I can make my template class a Q_OBJECT type.
I've got a template, defined like this:
template<typename T = QGraphicsObject>
class PreviewGraphicsItem : public T, // must be some kind of QObject
public PreviewBase,
public ControlPoint::Delegate
{
// Q_OBJECT
// the above line will cause compiler errors - wonder what the work-
around is?
public:
// magic stuff goes here...
};
What I really want to do is put a Q_OBJECT decl just above the public:
access specifier, but that doesn't work (compiler complains bitterly).
The class defines common functionality for an object that sits in a
preview window (within a graphics scene). It will always have a
template parameter that is derived from QObject.
The reason I want to put the Q_OBJECT macro in there, is because I'd
like to implement Q_PROPERTY statements at this level in the hierarchy.
Your ideas are appreciated,
Thanks
--
John Clayton
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest
---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.
"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."
"Please consider our environment before printing this email."
More information about the Qt-interest-old
mailing list