从WIndows中的命令提示符运行QT应用程序
Running a QT application from Command promt in WIndows
我制作了一个小的QT应用程序,我正试图通过Windows上的命令提示符运行它:
#include <QMainWindow>
#include <QLabel>
int main(int argc,char* argv[])
{
QMainWindow a(argc,argv)
QLabel *NewLabel = new QLabel("Hi i am a label");
NewLabel->show();
return a.exec();
}
执行qmake -project
之后然后CCD_ 2然后我尝试make
,这里它失败了,并出现以下错误:
D:TestPrg>make
make -f Makefile.Debug
make[1]: Entering directory `D:/TestPrg'
Makefile.Debug:58: *** missing separator. Stop.
make[1]: Leaving directory `D:/TestPrg'
make: *** [debug] Error 2
如果我们查看makefile.debug
的第58行,并在"<<"之前添加一个TAB,它会在其他行号处抱怨。所以我觉得编译器选项有问题,有人能指导它如何工作吗。
感谢
我刚刚在我的机器上做了一个示例。代码如下,但您至少有几个错误,即:
-
您使用QMainWindow作为应用程序,因为它似乎与QApplication相反。这不会编译。
-
相应地,您需要包括QApplication而不是QMainWindow。
-
在主函数的第一条语句之后,您缺少一个分号。
-
您在堆上构造了一个
QLabel
,这是不必要的。在这个特定的场景中,它可以是一个简单的堆栈对象。 -
您使用调用qmake作为
qmake -foo
,而不仅仅是qmake
或make foo
。 -
您正试图在Windows命令提示符中使用"make",而不是
nmake
或jom
。如果您使用Visual Studio和MSVC,请不要将其与mingw、cygwin和其他东西混合使用。只需使用nmake,否则,对后一个选项使用make。
main.cpp
#include <QApplication>
#include <QLabel>
int main(int argc, char **argv)
{
QApplication a(argc, argv);
QLabel NewLabel("Hi i am a label");
NewLabel.show();
return a.exec();
}
main.pro
TEMPLATE = app
TARGET = main
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
SOURCES += main.cpp
构建并运行
* qmake
* nmake
* main.exe
相关文章:
- 如何在MS Visual Studio 2019中运行QT UI
- 在 Ubuntu 服务器上运行 QT 应用程序时崩溃
- 运行Qt时处理退出代码0xC0000135 hello world
- 如何在 qt 中从另一个线程运行 qt并发时关闭程序
- qt.bluetooth:虚拟后端正在运行.Qt蓝牙模块在Raspbian上不起作用
- 在Raspbian lite上运行Qt Quick(EGLFS)
- 将QProcess窗口带到前面(运行QT助手)
- 必须在客户端计算机上安装的内容才能运行QT快速应用程序
- 无法运行Qt C++发布版本。 'The procedure entry point could not be located'
- 运行Qt 5.10事件循环howto的Windows服务service_WIN32_OWN_PROCESS
- 通过远程桌面运行 qt 创建器
- 通过php(LINUX)运行Qt生成的可执行文件(EXE)
- 从WIndows中的命令提示符运行QT应用程序
- 无法在Windows中运行Qt应用程序
- 我尝试在linuxLite上使用qt-creator运行qt-vtk项目
- 在Linux(Ubuntu 13.10和14.04)下运行Qt C++代码,而无需QtCoreApplication/Q
- 运行QT Creator时OpenGL出现问题
- 在没有IDE的情况下运行Qt程序
- 在while循环中运行Qt程序
- 如何在GPU上而不是在CPU上运行qt应用程序