[Qt-interest] qmake and scope: prevent moc from moc'ing file?

Scott Aron Bloom Scott.Bloom at onshorecs.com
Thu Feb 10 18:05:49 CET 2011


-----Original Message-----
From: qt-interest-bounces+scott.bloom=onshorecs.com at qt.nokia.com
[mailto:qt-interest-bounces+scott.bloom=onshorecs.com at qt.nokia.com] On
Behalf Of Oliver.Knoll at comit.ch
Sent: Thursday, February 10, 2011 6:14 AM
To: qt-interest at trolltech.com
Subject: [Qt-interest] qmake and scope: prevent moc from moc'ing file?

Hi,

I hit a rather esoteric problem: it seems that when running qmake it
does not prevent moc from running on files which are in a different
scope. That is on Qt 4.7.1 (MinGW binary build).

This is my scenario: I have an interface Foo.h, which is implemented by
platform-specific code, as in Foo_Windows, Foo_Mac etc. The source and
header files are naturally placed in qmake scopes, as in:

if (macx) {
    HEADERS += Foo_Mac.h
    SOURCES += Foo_Mac.cpp
} else:win32 {
    HEADERS += Foo_Windows.h
    SOURCES += Foo_Windows.cpp
} etc.

This compiles and links all fine, as expected.

Now for the Mac implementation - and currently only for the Mac - I
wanted to also subclass from QObject, so I did:

// Foo_Mac.h
class Foo : public QObject, public Foo
{
    Q_OBJECT // workaround: remove this (if possible)
public:
    ....
};
------------------
SOmethings not right...

I dot this all the time, and have no problems at all.. Heck the Qt
distro does this...

I would turn on the -Wall and the --debug flags and see whats going on.

You may have it set that for some reason the mac area is always true

Scott



More information about the Qt-interest-old mailing list