QT 中的 moc 不会编译我的 c++头文件。说它太不同了

发布于 2024-08-07 01:19:53 字数 2134 浏览 10 评论 0原文

好吧,wtf 这是当我尝试 moc 我的头文件之一时 moc 告诉我的。我通过 Qt 4.5.3 命令提示符执行此操作,它说:

C:\Documents and Settings\The Fuzz\Desktop\GUI2>moc App_interface.h /**************************************************************************** ** Meta object code from reading C++ file 'App_interface.h' ** ** Created: Mon Oct 12 16:58:11 2009 ** by: The Qt Meta Object Compiler version 61 (Qt 4.5.3) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include "App_interface.h" #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'App_interface.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 61 #error "This file was generated using the moc from 4.5.3. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE static const uint qt_meta_data_App_interface[] = { // content: 2, // revision 0, // classname 0, 0, // classinfo 0, 0, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0 // eod }; static const char qt_meta_stringdata_App_interface[] = { "App_interface\0" }; const QMetaObject App_interface::staticMetaObject = { { &QWidget::staticMetaObject, qt_meta_stringdata_App_interface, qt_meta_data_App_interface, 0 } }; const QMetaObject *App_interface::metaObject() const { return &staticMetaObject; } void *App_interface::qt_metacast(const char *_clname) { if (!_clname) return 0; if (!strcmp(_clname, qt_meta_stringdata_App_interface)) return static_cast<void*>(const_cast< App_interface*>(this)); return QWidget::qt_metacast(_clname); } int App_interface::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; return _id; } QT_END_MOC_NAMESPACE C:\Documents and Settings\The Fuzz\Desktop\GUI2>

有什么想法吗???我正在尝试使用 Q_OBJECT 宏。

ok wtf this is what moc tells me when i try to moc one of my header files. im doing this through Qt 4.5.3 command prompt and it says this:

C:\Documents and Settings\The Fuzz\Desktop\GUI2>moc App_interface.h /**************************************************************************** ** Meta object code from reading C++ file 'App_interface.h' ** ** Created: Mon Oct 12 16:58:11 2009 ** by: The Qt Meta Object Compiler version 61 (Qt 4.5.3) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include "App_interface.h" #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'App_interface.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 61 #error "This file was generated using the moc from 4.5.3. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE static const uint qt_meta_data_App_interface[] = { // content: 2, // revision 0, // classname 0, 0, // classinfo 0, 0, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0 // eod }; static const char qt_meta_stringdata_App_interface[] = { "App_interface\0" }; const QMetaObject App_interface::staticMetaObject = { { &QWidget::staticMetaObject, qt_meta_stringdata_App_interface, qt_meta_data_App_interface, 0 } }; const QMetaObject *App_interface::metaObject() const { return &staticMetaObject; } void *App_interface::qt_metacast(const char *_clname) { if (!_clname) return 0; if (!strcmp(_clname, qt_meta_stringdata_App_interface)) return static_cast<void*>(const_cast< App_interface*>(this)); return QWidget::qt_metacast(_clname); } int App_interface::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; return _id; } QT_END_MOC_NAMESPACE C:\Documents and Settings\The Fuzz\Desktop\GUI2>

any ideas??? im trying to use the Q_OBJECT Macro.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

多像笑话 2024-08-14 01:19:53

moc 将其输入标头转换为生成的文件,该文件打印在其输出上。您应该使用如下命令将其输出发送到文件:

moc App_interface.h > App_interface.h_moc

然后包含该文件。

如果您使用 QMake,我相信此过程是自动化的。

moc converts its input header into a generated file, which is printed on its output. You should send its output to a file, with a command like:

moc App_interface.h > App_interface.h_moc

then include that.

If you're using QMake, I believe this process is automated.

仅冇旳回忆 2024-08-14 01:19:53

这也可能有帮助:您需要在其他类之前从 QObject 继承: http://doc.trolltech.com/4.1/moc.html#multiple-inheritance-requires-qobject-to-be-first

根据之前的回复,使用 qmake 更好。

我强烈建议使用 IDE Qt Creator,而不是从命令行构建。

This may also help: you need to inherit from QObject before other classes: http://doc.trolltech.com/4.1/moc.html#multiple-inheritance-requires-qobject-to-be-first.

As per the previous reply, it's much better to use qmake.

I'd strongly recommend using an IDE Qt Creator, rather than building from the command line.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文