是否有可能让QT创建者自动将变量添加到.pro文件中

时间:2021-08-23 23:14:58

I've now started to dabble with QT and I was wondering if there was a way to get QT creator to automatically add variables to the project file. For example, I usually use C++11 code so it would be nice if QT could put CONFIG += c++11 in the .pro file automatically when I start a new project. I looked around in the options but I can't make sense of some sections so maybe it's right in front of my face?

我现在开始涉足QT,我想知道是否有办法让QT创建者自动将变量添加到项目文件中。例如,我通常使用C ++ 11代码,因此当我开始一个新项目时,如果QT可以自动在.pro文件中放置CONFIG + = c ++ 11,这将是很好的。我在选项中四处看看,但我无法理解某些部分,所以也许它就在我面前?

1 个解决方案

#1


0  

You can edit the wizard files of Qt Creator. The files are in the following directory:

您可以编辑Qt Creator的向导文件。这些文件位于以下目录中:

Qt-Dir/Tools/QtCreator/share/qtcreator/templates/wizards/

If you look at the directory there are some folders related to different wizards. For example if you look in to the "plaincppapp/qmake" folder, there you can see a "project.pro" file which is a template pro file. You can just edit that file like:

如果查看目录,则会有一些与不同向导相关的文件夹。例如,如果您查看“plaincppapp / qmake”文件夹,则可以看到“project.pro”文件,该文件是模板专业文件。您可以编辑该文件,如:

TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt

CONFIG += C++11  #added this line

SOURCES += main.cpp

Next time you create a project by that wizard, your custom pro would be created for the project.

下次通过该向导创建项目时,将为项目创建自定义专业版。

#1


0  

You can edit the wizard files of Qt Creator. The files are in the following directory:

您可以编辑Qt Creator的向导文件。这些文件位于以下目录中:

Qt-Dir/Tools/QtCreator/share/qtcreator/templates/wizards/

If you look at the directory there are some folders related to different wizards. For example if you look in to the "plaincppapp/qmake" folder, there you can see a "project.pro" file which is a template pro file. You can just edit that file like:

如果查看目录,则会有一些与不同向导相关的文件夹。例如,如果您查看“plaincppapp / qmake”文件夹,则可以看到“project.pro”文件,该文件是模板专业文件。您可以编辑该文件,如:

TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt

CONFIG += C++11  #added this line

SOURCES += main.cpp

Next time you create a project by that wizard, your custom pro would be created for the project.

下次通过该向导创建项目时,将为项目创建自定义专业版。