MOC adds namespace to class names
I have this very strange problem while compiling a project. It seems like MOC is adding a namespace to the class name that was moc'ed even though it was not mentioned anywhere in the file / class.
However, the namespace does exist in the library I am using, but it is hidden in the header files and I do not use it in the UI files. This is what the MOC generates:
const QMetaObject SmpTl::CaptureController::staticMetaObject = {
{ &QObject::staticMetaObject, qt_meta_stringdata_SmpTl__CaptureController,
qt_meta_data_SmpTl__CaptureController, 0 }};
The SmpTl namespace is not mentioned anywhere in the CaptureController declaration, but it appears in the .cpp file generated by the MOC.
I am using Visual Studio with QT integration.
a source to share
SmpTl is the CaptureController namespace defined in because it was found using MOC.
The Q_OBJECT macro expands in the staticMetaObject variable declaration inside your class definition (among other things, it expands). The MOC file contains the definition of this variable.
If this is not correct, please post a Qt version and a stripped down version of your header file.
a source to share
I also ran into this problem. I had some code that looked like this:
namespace foo {
#ifdef _WIN32
... // This code was fine
#else
#error Not Supported
#endif
}
This convoluted MOC into namespace with mouse foo is never closed. Apparently it didn't know that _WIN32 was defined and caused the fact that I forgot to put quotes around the error message. Changing it to
#error "Not Supported"
fixed my problem.
a source to share