qmake不添加小部件 [英] qmake does not add widgets
问题描述
我有一个简单的程序。我的程序是:
#include< QApplication>
#include< QLabel>
int main(int argc,char * argv [])
{
int rc;
QApplication app(argc,argv);
QLabel * label = new QLabel(Hello Qt!);
label-> show();
rc = app.exec();
return(rc);
}
我想在命令行中编译和构建这个代码。
i已安装qt和mingw。
首先我的命令是:
qmake -project
然后我输入此命令。
qmake
pro文件是:
TEMPLATE = app
TARGET = HELLO
INCLUDEPATH + =。
#输入
SOURCES + = hello.cpp
i认为这个文件必须inclue'QT + = widgets',但它doesnt。我不知道为什么。
最后,我调用mingw make
并且它给出错误。
文件QT + = widgets然后调用mingw-make,它工作和创建.exe文件。
然后我的问题是,为什么qmake自动添加 QT + = widgets
,我该怎么做呢?我不想手动添加。
我该怎么做?我不想手动添加。
您可以执行以下操作:
2)qmake -projectQT + = widgets
$ p b $ b
但没有更多。
此外,请注意,您可以使用 greaterThan(QT_MAJOR_VERSION,4):QT + = widgets
与Qt 4兼容,如果这对你很重要,因为小部件在gui模块中的Qt 4和core和gui默认添加。他们被放入自己的小部件模块在Qt 5。
i have a simple program. my program is:
#include <QApplication>
#include <QLabel>
int main(int argc, char *argv[])
{
int rc ;
QApplication app(argc, argv);
QLabel *label = new QLabel("Hello Qt!");
label->show();
rc = app.exec();
return(rc) ;
}
i want to compile and build this code in command line. i have installed qt and mingw.
first my command is:
qmake -project
then i give this command.
qmake
then qmake creates .pro file which is:
TEMPLATE = app
TARGET = HELLO
INCLUDEPATH += .
# Input
SOURCES += hello.cpp
i think this file must inclue ' QT += widgets' but it doesnt. i dont know why. finally, i call mingw make
and it gives error.
when i add .pro file QT += widgets then call mingw-make, it works and creates .exe file.
then my question is that, why qmake automatically add QT += widgets
, how can i do this? i dont want to add manually.
how can i do this? i dont want to add manually.
You can do the following things:
1) You could use QtCreator and select the widget based application.
2) qmake -project "QT += widgets"
but nothing more. QMake is not a C++ code project parser.
Also, note that you could use greaterThan(QT_MAJOR_VERSION, 4):QT+=widgets
to be compatible with Qt 4 if that matters for you since the widgets were in the gui module for Qt 4 and core and gui are added by default. They were put into their own widgets module in Qt 5.
这篇关于qmake不添加小部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!