我关注了Netbeans' guide使用 QT 创建基本应用程序。 项目构建成功但运行失败,没有任何解释。
我正在运行带有 MinGW 和 QT4.8 的 W8 x64(从 netbeans 的指南链接下载)。
这是 C++ 文件代码(大部分是自动创建的):
main.cpp :
#include <QtGui/QApplication>
#include "UI_main.h"
int main(int argc, char *argv[]) {
// initialize resources, if needed
// Q_INIT_RESOURCE(resfile);
QApplication app(argc, argv);
// create and show your widgets here
UI_main main_w;
main_w.show();
return app.exec();
}
UI_main.h :
#ifndef _UI_MAIN_H
#define _UI_MAIN_H
#include "ui_UI_main.h"
class UI_main : public QMainWindow {
Q_OBJECT
public:
UI_main();
virtual ~UI_main();
private:
Ui::UI_main widget;
};
#endif /* _UI_MAIN_H */
ui_UI_main.h :
#ifndef UI_UI_MAIN_H
#define UI_UI_MAIN_H
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QGroupBox>
#include <QtGui/QHeaderView>
#include <QtGui/QMainWindow>
#include <QtGui/QMenuBar>
#include <QtGui/QStatusBar>
#include <QtGui/QWidget>
QT_BEGIN_NAMESPACE
class Ui_UI_main
{
public:
QWidget *centralwidget;
QGroupBox *groupBox;
QMenuBar *menubar;
QStatusBar *statusbar;
void setupUi(QMainWindow *UI_main)
{
if (UI_main->objectName().isEmpty())
UI_main->setObjectName(QString::fromUtf8("UI_main"));
UI_main->resize(800, 600);
centralwidget = new QWidget(UI_main);
centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
groupBox = new QGroupBox(centralwidget);
groupBox->setObjectName(QString::fromUtf8("groupBox"));
groupBox->setGeometry(QRect(300, 210, 120, 80));
UI_main->setCentralWidget(centralwidget);
menubar = new QMenuBar(UI_main);
menubar->setObjectName(QString::fromUtf8("menubar"));
menubar->setGeometry(QRect(0, 0, 800, 21));
UI_main->setMenuBar(menubar);
statusbar = new QStatusBar(UI_main);
statusbar->setObjectName(QString::fromUtf8("statusbar"));
UI_main->setStatusBar(statusbar);
retranslateUi(UI_main);
QMetaObject::connectSlotsByName(UI_main);
} // setupUi
void retranslateUi(QMainWindow *UI_main)
{
UI_main->setWindowTitle(QApplication::translate("UI_main", "UI_main", 0, QApplication::UnicodeUTF8));
groupBox->setTitle(QApplication::translate("UI_main", "GroupBox", 0, QApplication::UnicodeUTF8));
} // retranslateUi
};
namespace Ui {
class UI_main: public Ui_UI_main {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_UI_MAIN_H
UI_main.cpp :
#include "UI_main.h"
UI_main::UI_main() {
widget.setupUi(this);
}
UI_main::~UI_main() {
}
UI_main.ui 只包含一个用 QTDesigner 创建的组框。
错误消息:
RUN FAILED (exit value -1 073 741 819, total time: 2s)
我尝试使用 Windows 控制台和兼容模式 W7 和 XP 运行它,结果相同。
有什么想法吗? 提前致谢。
最佳答案
代码没问题,在 Qt Creator 中运行没有任何错误。
exit value -1 073 741 819
表示您使用了错误的库链接或不匹配的 header 或构建版本。请检查项目链接器、它们的版本、arch 等。
关于c++ - 如何让 QT 4.8 应用程序与 Netbeans 7.3 一起运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15663457/