Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt Creator variables to add into .pro file

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?

like image 993
Emuser3616399 Avatar asked May 15 '14 07:05

Emuser3616399


People also ask

How do I set environment variables in Qt?

You can edit existing environment variables or add, reset and unset new variables based on your project requirements. To globally change the system environment from the one in which Qt Creator is started, select Edit > Preferences > Environment > System, and then select Change in the Environment field.

What is the use of .pro file in Qt?

The purpose of a . pro file is to list the source files that are involved in a project. Since qmake is used for building Qt and its associated tools, it knows Qt very well and can generate rules for invoking moc, uic, and rcc.

What is $$ PWD?

pwd stands for Print Working Directory. It prints the path of the working directory, starting from the root. pwd is shell built-in command(pwd) or an actual binary(/bin/pwd). $PWD is an environment variable which stores the path of the current directory.


1 Answers

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

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:

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.

like image 55
Nejat Avatar answered Oct 01 '22 08:10

Nejat