qt-interest@trolltech.com
[Top] [All Lists]

Re: Q_OBJECT in implementation file

Subject: Re: Q_OBJECT in implementation file
From: "Fanda Vacek"
Date: Tue, 25 Jul 2006 18:12:03 +0200
thank you very much

Fanda

On Tue, 25 Jul 2006 17:41:38 +0200, Volker Hilsheimer <unwatched@xxxxxxx> wrote:


"Fanda Vacek" <fanda.vacek@xxxxxxxx> wrote in message
news:op.tc83fecjasg76k@xxxxxxxxxxxxxxxxxxxxxxxx
The QT4 documnetation does not tell a much about (QT3 doc does). I've
found only this in a moc chapter.

For Q_OBJECT class declarations in implementation (.cpp) files, we
suggest  a makefile rule like this:
    foo.o: foo.moc

    foo.moc: foo.cpp
            moc $(DEFINES) $(INCPATH) -i $< -o $@

This guarantees that make will run the moc before it compiles foo.cpp.
You  can then put
    #include "foo.moc"

at the end of foo.cpp, where all the classes declared in that file are
fully known.


After some playing and inspecting QT4 sources, I've found that I have to
include 2 files 'sourcename.moc' and 'moc_sourcename.cpp' at the end of
'sourcename.cpp', but I still do not know why.

Fanda

You only have to #include the .moc file. The moc_*.cpp file can be
compiled as a separate compilation unit, where as the .moc file cannot
(the declaration of the class that the .moc file implements is not
available).

This is really all the same as in Qt 3.

Volker





--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

--
To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with 
"unsubscribe" in the subject or the body.
List archive and information: http://lists.trolltech.com/qt-interest/

<Prev in Thread] Current Thread [Next in Thread>