QT 学习笔记(一)
QT简介
Qt(官方发音 [kju:t],音同 cute)是一个跨平台的 C++ 开发库,主要用来开发图形用户界面(Graphical User Interface,GUI)程序,当然也可以开发不带界面的命令行(Command User Interface,CUI)程序。
Qt 虽然经常被当做一个 GUI 库,用来开发图形界面应用程序,但这并不是 Qt 的全部;Qt 除了可以绘制漂亮的界面(包括控件、布局、交互),还包含很多其它功能,比如多线程、访问数据库、图像处理、音频视频处理、网络通信、文件操作等,这些 Qt 都已经内置了。
QT 安装
依次进入: archive -> qt/ -> 5.9/ ->
任意一个版本
根据自己需求下载即可
qt5.9是一个长期支持的版本
下载好后, 安装示意图


一定要选择环境!
main()函数说明
#include "widget.h"#include <QApplication>// argc 命令行变量数量 argv命令行变量数组int main(int argc, char *argv[]){// 应用程序对象, 有且仅有一个QApplication a(argc, argv);// 窗口对象Widget w;w.show();return a.exec(); // 相当于pause}
qmake-file .pro文件说明
QT += core guigreaterThan(QT_MAJOR_VERSION, 4): QT += widgetsCONFIG += c++11# The following define makes your compiler emit warnings if you use# any Qt feature that has been marked deprecated (the exact warnings# depend on your compiler). Please consult the documentation of the# deprecated API in order to know how to port your code away from it.DEFINES += QT_DEPRECATED_WARNINGS# You can also make your code fail to compile if it uses deprecated APIs.# In order to do so, uncomment the following line.# You can also select to disable deprecated APIs only up to a certain version of Qt.#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0SOURCES += \main.cpp \widget.cppHEADERS += \widget.hFORMS += \widget.ui# Default rules for deployment.qnx: target.path = /tmp/$${TARGET}/binelse: unix:!android: target.path = /opt/$${TARGET}/bin!isEmpty(target.path): INSTALLS += target
QT +=QT的模块, 如果用到就要加上greaterThan(QT_MAJOR_VERSION, 4): QT += widgets # 大于4版本包含widget模块!isEmpty(target.path): INSTALLS += target # 目标文件生成路径SOURCES源文件HEADERS头文件
QT常用快捷方式

