Search code examples
c++qtqt-creatorqmakewizard

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?


Solution

  • 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.