c++ - 如何让 QT 4.8 应用程序与 Netbeans 7.3 一起运行?

标签 c++ qt netbeans qt4 netbeans-7

我关注了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 中运行没有任何错误。

enter image description here

exit value -1 073 741 819 表示您使用了错误的库链接或不匹配的 header 或构建版本。请检查项目链接器、它们的版本、arch 等。

关于c++ - 如何让 QT 4.8 应用程序与 Netbeans 7.3 一起运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15663457/

相关文章:

c++ - Qt QGraphicsview 如何 Hook 调整事件大小

c++ - 如何防止图标被突出显示?

Netbeans Jmeter "External Edit"不工作?

c++ - 2D Sprite(背景)前面的 3D 物体,怎么样?

c++ - 哪个版本的 GNU GCC 支持 TR1 外部模板?

c++ - Boost::Spirit mini_c 教程

c++ - QML QTQuick ChartView 将指针传递给 C++

c++ - 类模板的别名

java - 在一群程序员之间共享新版本 Java 源代码的最佳方式是什么?

c++ - NetBeans IDE gcc 编译器优化选项