MOC将名称空间添加到类名称

MOC将名称空间添加到类名称

本文介绍了MOC将名称空间添加到类名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在编译项目时,我遇到了一个非常奇怪的问题.MOC似乎正在向要移动的类名添加一个名称空间,尽管在文件/类的任何地方都没有提及.

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.

但是,命名空间存在于我使用的库中,但隐藏在头文件中很远,并且我不在UI文件中使用它.这是MOC生成的:

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 }};

CaptureController的声明中未在任何地方提及SmpTl命名空间,但它出现在MOC生成的.cpp文件中.

The SmpTl namespace is not mentioned anywhere in the declaration of CaptureController, but it appears in the MOC-generated .cpp file.

我正在使用带有QT集成的Visual Studio.

I'm using Visual Studio with the QT integration.

推荐答案

SmpTlCaptureController的定义名称空间,由MOC找到.

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

Q_OBJECT宏在类定义内扩展为staticMetaObject变量的声明(除其他内容外). 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.

如果这不正确,请发布您的Qt版本和头文件的精简版本.

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

这篇关于MOC将名称空间添加到类名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 01:28