[Interest] Moc Builder Concepts

William Blevins wblevins001 at gmail.com
Fri Jul 17 23:11:43 CEST 2015


I have a question regarding the Moc builder and expected source code
dependency graphs.

> From http://doc.qt.io/qt-4.8/moc.html
>
>
>
> The moc tool reads a C++ header file. If it finds one or more class
declarations that contain the Q_OBJECT macro, it produces a C++ source file
containing the meta-object code for those classes. Among other things,
meta-object code is required for the signals and slots mechanism, the
run-time type information, and the dynamic property system.I am looking at
some older QT code defined like so:

Moc builder is called on bbb,cpp which generates bbb.moc (if I understand
correctly) where bbb.cpp is define as:

> #include "my_qobject.h"
>
> void bbb(void) Q_OBJECT
>
> #include "bbb.moc"

As written this code contains a dependency cycle where "bbb.moc depends on
bbb.cpp (by explicit creation) and bbb.cpp depends on bbb.moc (by implicit
inclusion).

Is Moc designed to created dependency cycles or is this simply bad code?
If this code is poorly structured, can someone give me an example for best
practice?

V/R,
William
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150717/bcf01d2a/attachment.html>


More information about the Interest mailing list