[Qt-interest] moc .cpp file in visual studio

Thiago Macieira thiago.macieira at trolltech.com
Tue Jun 30 09:35:22 CEST 2009


Linda Maria wrote:
>Thanks a lot all
>
>This is basically what I have been doing. That is, to create custom
> build to moc my .h files that include Q_OBJECT class declarations.
> However, I dont know how to handle .cpp files that include private
> Q_OBJECT class declarations. These files need to be moc-ed (to create
> .moc files) and compiled with C/C++ Compiler Tool. Does visual studio
> support this?

C++ source files that include the Q_OBJECT file must #include the .moc file 
at the end.

So:

class MyPrivate
{
    Q_OBJECT
    [...]
};
[...]
#include "myfile.moc"

And this .moc file (which is plain C++ source code) must not be compiled 
separately. It has to be #include'd.

-- 
Thiago Macieira - thiago.macieira (AT) nokia.com
  Senior Product Manager - Nokia, Qt Software
      Sandakerveien 116, NO-0402 Oslo, Norway
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090630/fb1b8442/attachment.bin 


More information about the Qt-interest-old mailing list