Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Revision as of 20:57, 20 September 2009 by Ikipou (Talk | contribs)

QObject and the Qt Object System

From Wiki
Jump to: navigation, search
{{{width}}}
Article Metadata
Tested with
Devices(s): Emulator
Compatibility
Platform(s): S60 3rd Edition, S60 5th Edition
Symbian
Article
Keywords: Q_OBJECT
Created: (29 Dec 2008)
Last edited: Ikipou (20 Sep 2009)

Introduction

The Q_OBJECT macro at the beginning of the class definition is necessary for all classes that define signals, slots or uses a service provided by the meta-object system.

The QObject class is the base class for the object that uses the meta-object system (like signals and slots). Q_OBJECT enables the meta-object feature and it must be written without ';' at the end of line.

Forgetting Q_OBJECT is a common error among beginners. The class will not compile, and the compiler shows some errors about some methods missing in the vtable.

Preconditions

Code Snippet

#include <QObject>
class Counter: public QObject
{
Q_OBJECT
//some code here
};
41 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×