Search code examples
c++qtcompilationmoc

MOC adding namespace to class names


I have this very strange problem while compiling the project. MOC seems to be adding a namespace to the class name being moc'ed, although it's not mentioned anywhere in the file/class.

The namespace, however, exists in a library which I use, but it's hidden far away in the header files and I don't use it in the UI files. This is what 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 declaration of CaptureController, but it appears in the MOC-generated .cpp file.

I'm using Visual Studio with the QT integration.


Solution

  • SmpTl is the namespace CaptureController is defined in, as it was found by MOC.

    The Q_OBJECT macro expands into the declaration of the staticMetaObject-variable inside your class definition (among other things it expands into). The MOC-file contains the definition of that variable.

    If this is not correct, please post your Qt version and a stripped down version of your header-file.