How to enable C++11 in Qt Creator ?

How to enable C++11 in Qt Creator?

Asked on December 14, 2018 in Qt.
Add Comment


  • 3 Answer(s)

    The best solution :

     CONFIG += c++11

    Add the .pro  file (see at the bottom of that web page). It requires Qt 5.

    The following answer is:

    QMAKE_CXXFLAGS += -std=c++11 (or QMAKE_CXXFLAGS += -std=c++0x)


    Its work with Qt 4.8 and gcc / clang.
     

    Answered on December 14, 2018.
    Add Comment

    Set this .pro file

    QMAKE_CXXFLAGS += -std=c++11

    or

    CONFIG += c++11

    Answered on December 14, 2018.
    Add Comment

    Alternative for handling both cases,

    # With C++11 support
    greaterThan(QT_MAJOR_VERSION, 4){
    CONFIG += c++11
    } else {
    QMAKE_CXXFLAGS += -std=c++0x
    }
    

    The  project files  can be handle  which Qt version if people using in the team, but want them to have C++11 enabled in any case.

    Answered on December 14, 2018.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.