初学QT,记录一下QT的学习之路,以前都是在VS下的编程环境,现在使用Qt Creator还是不太适应。
1.安装好QT之后,想创建工程很简单,和VS一样,乃至打开工程和创建新工程的快捷键都一样:
但是想像VS一样创建大工程包含许多模块,就得选择其他项目中的子项目目录集:
其后选择添加子项目等,这样就可以创建包含多模块工程,但是值得注意的是,qt里面的项目属性设置并不像VS一样直观,是在叫pro文件中配置项目属相的,UIModuls是C++库,MainControl为QT控制台程序,也是该工程的主模块:
使用pri文件进行文件筛选,先在本地创建文件夹,将自己的文件放入,建立pri文件,将文件导入:
在pro文件使用时将其包含进去,pro文件里面设置项目属性常用如下:
QT -= gui
QT += widgets//加载的模块
CONFIG += c++11 console //控制台C++11
CONFIG -= app_bundle
# 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
DESTDIR += $$PWD/../Bin //目标文件夹 生成数据存储位置
SOURCES += \
main.cpp //源文件
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
unix|win32: LIBS += -L$$PWD/../Bin/ -lUIModuls //库路径
INCLUDEPATH += $$PWD/../Bin //头文件包含路径
DEPENDPATH += $$PWD/../Bin //依赖性包含路径
以上,一个大型工程建立如上
来源:CSDN
作者:朕守山河
链接:https://blog.csdn.net/qq_42956179/article/details/104799797