[Interest] Heavily Commented Example: Simple Single Frontend with Two BackendsLow,

Thiago Macieira thiago.macieira at intel.com
Fri Oct 26 16:59:47 CEST 2012


On sexta-feira, 26 de outubro de 2012 07.42.01, d3fault wrote:
> Weird, I thought all QObject derived classes required the Q_OBJECT
> macro. What are the exact requirements for this? Only if you use
> signals/slots in the derived class?

Yes. You need it if you use the features provided by the meta object, which 
are:
 - signals
 - slots
 - other Q_INVOKABLE
 - properties
 - Q_ENUM
 - Q_CLASSINFO
 - qobject_cast
 - any access to metaObject(), including registering in QtDBus, QML, QtScript, 
   etc.

Starting in Qt 5, things change a little. Due to the new connection mechanism, 
you do not need Q_OBJECT to connect an existing signal to anything. That means 
you can use existing Qt classes without using moc in your application, 
provided you do use the new mechanism.

However, Qt plugins now require Q_OBJECT because moc generates some extra data 
that QPluginLoader needs to find.
-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20121026/fdf6e86a/attachment.sig>


More information about the Interest mailing list