[英]Using qmake as qmake -project
I want to make a GUI application using Qt and am not able to get started. 我想使用Qt制作GUI应用程序,但无法入门。 I wrote the following code in my editor:
我在编辑器中编写了以下代码:
#include <QApplication>
#include <QWidget>
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
QWidget window;
window.resize(250,150);
window.setWindowTitle("Simple example");
window.show();
return app.exec();
}
Then I make a project.pro
file in my current directory with the following content: 然后,在当前目录中制作一个具有以下内容的
project.pro
文件:
SOURCES = qt.cpp
HEADERS = QApplication QWidget
CONFIG += qt warn_on release
Then I type in terminal, qmake -project
but the terminal does nothing. 然后我输入终端
qmake -project
但是终端什么也不做。 Even the command prompt doesn't appear. 甚至命令提示符都不会出现。 It just sits idle as if waiting for something, like the following:
它只是闲置着,好像在等待什么,如下所示:
user@user:~$ qmake -project
_
How do I make it work? 我该如何运作?
The following line creates a project source file for you. 下一行为您创建一个项目源文件。
> qmake -project
> qmake-项目
The only thing in this case you need is .cpp & .h files for your project. 在这种情况下,您唯一需要的是项目的.cpp和.h文件。
Now, remove your project source file you've created. 现在,删除您创建的项目源文件。 In the directory, you need only .cpp & .h for your project (in your case there is only qt.cpp).
在目录中,您的项目仅需要.cpp和.h(在您的情况下,仅qt.cpp)。 Now, go to the terminal and type
现在,转到终端并输入
> qmake -project -o myproject.pro
> qmake -project -o myproject.pro
This line created a project source file for you and its name is "myproject". 该行为您创建了一个项目源文件,名称为“ myproject”。
Type (assuming there is only one project source file) 类型(假设只有一个项目源文件)
> qmake
> qmake
The above line created the Makefile. 上一行创建了Makefile。
Now, type 现在,输入
> make
>制作
The output (by default in mac) has the extension .app and its name is myproject.app. 输出(在Mac中默认情况下)的扩展名为.app,其名称为myproject.app。 Now to run it (in mac).
现在运行它(在Mac中)。
> open myproject.app
>打开myproject.app
As you see, you don't have full control over your project. 如您所见,您无法完全控制您的项目。 To overcome this problem, you need to create your own project source file ( which I prefer that).
为了克服这个问题,您需要创建自己的项目源文件(我更喜欢这样做)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.