How to use QObject/moc?

Andreas Pakulat apaku at gmx.de
Wed Apr 5 21:42:43 BST 2006


On 05.04.06 23:27:40, kitts wrote:
> I have added ":public QObject" beside the class and the "Q_OBJECT" keyword 
> in the class header as is in the other classes created by the class wizard. 
> I get the error
> 
> "/usr/share/qt3/include/qobject.h:211: error: 'QObject::QObject(const 
> QObject&)' is private"

The error is not the header of that class, it's how you use instances of
this class. You cannot copy construct QObjects and derived classes, so
if you do something like

MyClass c;

MyClass d(c);

it will trigger the above error. The same will happen if you write a
copy constructor for this newly-QObject-derived class and call the
parent (QObject's) copy constructor. Don't do that.

> I have also tried placing "#include filename.moc" at the bottom of the 
> implementation file.
> 
> How do I work with QObject and moc?

Make sure that your build-system runs moc on the header. Normally in KDE
projects this should be done automatically.

Andreas

-- 
It's all in the mind, ya know.

-
to unsubscribe from this list send an email to kdevelop-request at kdevelop.org with the following body:
unsubscribe »your-email-address«



More information about the KDevelop mailing list