When is a class added to the list of moc files

Falk Brettschneider gigafalk at yahoo.com
Mon Apr 17 17:20:22 UTC 2000


Werner Modenbach wrote:
> Recently we created a class which was derived from QFrame.
> Everything worked fine until we tried to create a signal.
> The linker reclaimed for a missing reference.
> It took us a long while to find out that there is no meta object created from
> our class. Where do I tell to build a meta object. Isn't it possible to do this
> automatically when detecting signals or slots?
> After we fixed this (by creating a new project and transfering the source to
> the prebuild classes - our project ist still small ;-)) now we tried to connect
> the signal to a slot of another class.
> This seend to work fine, but unfortinately when I debug until the emit
> statement the emit returns without calling the slot.
Signal-slot works only in classes that insert the Q_OBJECT macro right
at the beginning of its class definition:

class Falk : public Boss {

> Do I have to take care about some specialities to make this work?
Initially call ´tmake x.pro -o Makefile´. Tmake parses your sources and
headers for the Q_OBJECT macro and set the rules in your Makefile to
create and compile the meta objects. Those meta objects are inserted in
the moc_....cpp file and they are generated by a tool called ´moc´ (meta
object compiler). See the tmake-generated Makefile for rules that call
the moc.

But you don´t need to do anything except inserting Q_OBJECT.
Note: whenever you change your .pro-File, tmake is called automatically.

For further question look into the Qt documentation (section

Hope that helps,

Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.

More information about the KDevelop mailing list