Qt QMake moc文件被名称空间弄糊涂了
我有一个文件,看起来像:Qt QMake moc文件被名称空间弄糊涂了,qt,qt5,qmake,moc,Qt,Qt5,Qmake,Moc,我有一个文件,看起来像: #ifndef ENGINE_PLATFORM_AREAEDITOR_H #define ENGINE_PLATFORM_AREAEDITOR_H #include <QWidget> #include "../Widgets/QtSfmlWidget.h" namespace Engine { namespace World { class Area; } } //This tell's Qt's qmake to ignore the code b
#ifndef ENGINE_PLATFORM_AREAEDITOR_H
#define ENGINE_PLATFORM_AREAEDITOR_H
#include <QWidget>
#include "../Widgets/QtSfmlWidget.h"
namespace Engine { namespace World { class Area; } }
//This tell's Qt's qmake to ignore the code between MOC_SKIP_BEGIN and MOC_SKIP_END
// MOC_SKIP_BEGIN
#include "Engine/World/Area.h"
// MOC_SKIP_END
namespace Ui {
class AreaEditor;
}
class AreaEditor : public QWidget
{
Q_OBJECT
public:
Engine::World::Area area;
public:
explicit AreaEditor(QWidget *parent = 0);
~AreaEditor();
//...stuff....
private slots:
void on_markerTextEdit_textChanged();
void onDrawAreaScreen(sf::RenderTarget &renderTarget);
void onDrawAreaResized(const WindowSize &windowSize);
private:
Ui::AreaEditor *ui;
//...stuff....
};
#endif //ENGINE_PLATFORM_AREAEDITOR_H
头文件“Engine/World/Area.h”有一个名为“Area”的类,它位于名称空间“Engine”(实际上,它位于“Engine::World::”,两个嵌套的名称空间)中。这似乎在某种程度上混淆了QMake
如果我删除#include,将其注释掉,一切都可以编译(除了我必须预先声明'Area',然后只能将其用作类中的指针或引用)
因此,我尝试将#include包装在一个“MOC#u SKIP#u BEGIN”中,我可以在网上找到看似过时的引用,希望QMake会跳过该标题。不,仍然无法编译
有没有一种方法可以让我在编译时仍然能够包含我想要包含的标题?来自文档: 您可以显式地告诉moc不要解析头文件的某些部分。moc定义预处理器符号Q_moc_RUN 被主运行中心跳过
______/---------<-< Wrong
V V
void Engine::AreaEditor::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
AreaEditor *_t = static_cast<AreaEditor *>(_o);
switch (_id) {
case 0: _t->on_markerTextEdit_textChanged(); break;
case 1: _t->onDrawAreaScreen((*reinterpret_cast< sf::RenderTarget(*)>(_a[1]))); break;
case 2: _t->onDrawAreaResized((*reinterpret_cast< const WindowSize(*)>(_a[1]))); break;
default: ;
}
}
}
void AreaEditor::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
#ifndef Q_MOC_RUN
...
#endif