简体   繁体   English

在Qt中编译一个快速项目?

[英]Compile a quick project in Qt?

I want to compile this application in a command prompt (Windows): 我想在命令提示符(Windows)中编译此应用程序:

include "QtGui/QApplication"
include "QtGui/QMainWindow"

class Form1 : public QMainWindow
{
    Q_OBJECT

    public:

    Form1(QWidget *parent = 0, Qt::WFlags flags = 0);

    ~Form1();

};

Form1::Form1(QWidget *parent, Qt::WFlags flags) : QMainWindow(parent, flags)
{

}

Form1::~Form1()
{

}

int main(int argc, char * argv[])
{
    QApplication a(argc, argv);

    Form1 * frm = new Form1();
    frm->setWindowTitle("Hello Word !!!");
    frm->show();

    return a.exec();
}

What should I do? 我该怎么办?

Open the Qt Command Prompt and type: 打开Qt命令提示符并键入:

qmake -project
qmake
make

Alternatively, you could download Qt Creator to have a nice lightweight IDE that lets you compile your application by pushing a button :) 另外,您可以下载Qt Creator来获得一个不错的轻量级IDE,该IDE允许您通过按一个按钮来编译应用程序:)

Look an one of the numerous examples and demos supplied with Qt, copy an existing .pro file and adapt it to your use. 查看Qt提供的众多示例和演示之一,复制现有的.pro文件并使其适应您的使用。

Then copy the resulting compile instruction into a batch file, shell script, Makefile, emacs 'compile-command' variable, ... or whatever you prefer over the .pro file. 然后将生成的编译指令复制到批处理文件,shell脚本,Makefile,emacs'compile-command'变量等中,或将其复制到.pro文件中。 I have chose the emacs 'compile-command' route myself for some small Qt test apps and test cases. 我为一些小型Qt测试应用程序和测试用例选择了emacs的“编译命令”路由。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM