日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

qt怎么创建pri文件

發布時間:2024/9/27 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 qt怎么创建pri文件 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

提要

當多人合作開發一個項目的時,若每人創建一個工程,就會出現同一個項目中多個pro文件。pri文件就是解決多個pro文件的一種方式,方便了最后代碼的合并。

示例

1.如何建立pri文件
2.pri文件與pro文件之間的聯系怎樣建立

如何建立pri文件

創建一個項目,在項目文件夾下創建一個文本文件,即txt文件,創建后修改其名稱為xxx.pri;

.pri文件與pro文件之間的聯系怎樣建立

繼上面創建好項目和pri文件后,用QtCreate打開項目,進入.pro文件,假如你的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 \largescreenlistwidget.cppHEADERS += \dataStruct.h \largescreenlistwidget.hFORMS += \largescreenlistwidget.ui# Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += targetDISTFILES +=

可以看到pro文件包含了源文件,頭文件,ui文件,此時將源文件,頭文件,ui文件部分,剪切下來粘貼到pri文件中。
下面是pri文件的內容:

SOURCES += \main.cpp \largescreenlistwidget.cppHEADERS += \dataStruct.h \largescreenlistwidget.hFORMS += \largescreenlistwidget.ui

pri文件保存之后,進入到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.0include(largescreenlistwidget.pri)# Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += targetDISTFILES +=

相比于之前的pro文件,此時的pro文件將pri文件的 內容包含了進來,實際上相當于將之前的源文件,頭文件,ui文件放在了pri文件,將pri文件當作了頭文件一樣被包含進來。即之前包含的源文件,頭文件,ui文件部分,變為了include(largescreenlistwidget.pri)。
參考
https://blog.csdn.net/qq_41673920/article/details/96153657

總結

以上是生活随笔為你收集整理的qt怎么创建pri文件的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。