PDA

View Full Version : Qt Creator Problem with shadow build and moc_ file while creating new widget



SvenA
8th June 2016, 12:34
Hello!

I have a problem using QtCreator (with qmake) and shadow builds. I'm using QtCreator 3.6.1.
Maybe somebody could give me a hint.

The problem is the following:
I created a new spinbox "SpinBox64" (inherited from QSpinBox) and my new widget includes a moc file in the widget's .cpp directly.

It compiles and works fine, if I do not use shadow builds.
If I do, I get the following errors:

error: invalid use of incomplete type 'class SpinBox64Private'
note: forward declaration of 'class SpinBox64Private'

This is, because in the shadow build it tries to compile the moc file itself (whereas it's correctly included and not compiled separately in the non-shadow build).

The "widget_spinbox64.cpp" has the following last line:

#include "moc_widget_spinbox64.cpp"

Does anybody has an idea how to solve this problem?

anda_skoa
8th June 2016, 19:53
For including the moc file it has to be called exactly like the cpp file, just with .moc as the extension.

In your case it should probably be


#include "widget_spinbox64.moc"


Cheers,
_