QT 学习(一) -- hello QT

环境配置相关文章:
转自:
https://blog.csdn.net/zusi_csdn/article/details/80085943

基于QT 5.10.1环境配置:
C:\Qt\Qt5.10.1\5.10.1\mingw53_32\bin;
C:\Qt\Qt5.10.1\Tools\mingw530_32\bin;

通过命令行的方式编译QT源程序

  • 启动 QT 命令行
  • 进入源程序所在目录
  • 命令:
  1. qmake -project //根据目录中的源码生成工程文件
  2. qmake hello_qt.pro //根据工程文件生成makefile文件
  3. mingw32-make //根据makefile进行编译

QT4.7.4相关源码测试代码

#include <QApplication>
#include <QMainWindow>
#include <QPushButton>

int main(int argc, char* argv[])
{
	QApplication a(argc,argv);
	QMainWindow w;
	QPushButton b(&w);
	b.setText("hello QT...");
	w.show();
	return a.exec();
}

QT 5.10.1 for Desktop(MinGW 5.3.0.32 bit)编译报错问题:
D:\qt_test\lesson4>mingw32-make
mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory ‘D:/qt_test/’
g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -Wall -W -Wextra -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I. -I. -IC:\Qt\Qt5.10.1\5.10.1\mingw53_32\include -IC:\Qt\Qt5.10.1\5.10.1\mingw53_32\include\QtGui -IC:\Qt\Qt5.10.1\5.10.1\mingw53_32\include\QtANGLE -IC:\Qt\Qt5.10.1\5.10.1\mingw53_32\include\QtCore -Irelease -IC:\Qt\Qt5.10.1\5.10.1\mingw53_32\mkspecs\win32-g++ -o release\HelloQt.o HelloQt.cpp
HelloQt.cpp:1:24: fatal error: QApplication: No such file or directory
compilation terminated.
Makefile.Release:118: recipe for target ‘release/HelloQt.o’ failed
mingw32-make[1]: *** [release/HelloQt.o] Error 1
mingw32-make[1]: Leaving directory ‘D:/qt_test/lesson4’
Makefile:36: recipe for target ‘release’ failed
mingw32-make: *** [release] Error 2

fatal error: QApplication: No such file or directory编译报错问题解决:
转自:
https://blog.csdn.net/friendbkf/article/details/45440175

可编译代码:

#include <QtWidgets/QApplication>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QMainWindow>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
   	QPushButton pushButton(QObject::tr("hello QT!"));
    pushButton.show();
    return a.exec();
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值