一. 创建Qt程序
1.新建一个项目
2.选择项目的模板
3.保存项目的路径
注意事项:
名称:1.不能出现中文
2.不能有空格
保存路径:不能出现中文路径
4.定义系统
5.创建窗口类
5.1基类的三种选择
QWidget、QMainWindow、QDialog
我选择的是QWidget,然后我的类名字是myQWidget
6.检查是否有自己需要的文件
二. 了解main函数(如图)
1.1QApplication a有且只有一个一个
1.2需要调用show才显示窗口
三. 了解.pro文件
QT += core gui //Qt包含的模块 核心模块 、图形模块
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets //大于4版本以上,包含QT += widgets模块
TARGET = untitled //可以修改程序名字
TEMPLATE = app //template->模板 应用程序模板 Application
CONFIG += 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.0
SOURCES += \ //源文件
main.cpp \
mywidget.cpp
HEADERS += \ //头文件
mywidget.h
FORMS += \
mywidget.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
1.基本模块了解图
主要学习的是core与gui模块,其他模块以后再说
2.pro文件中的其他模板
四. 了解头文件
五. 快捷了解Qt的使用
1.快捷键的用法
2.帮助文件
2.1打开帮助文档的方法一
第一步点击F1,窗口会变成如下图所示,点击Esc即可恢复原来的界面。
再一次点击F1时,帮助文档将变成如下图所示,点击Esc则恢复到上图所示。
2.2打开帮助文档的方法二及方法三
1.方法二:点击左侧的帮助即可
2.方法三:
找到在下载的Qt文件中找到根据自己保持的方式找到到这个,并且在里面找到assistance这个应用程序,点击打开即可运用。(推荐使用这个,会比较便捷)