Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable C++11 in Qt Creator?

Tags:

c++

c++11

qt

People also ask

Does Qt support C ++ 11?

When you read that "Qt Creator supports C++11" it means that the code-completion engine (Clang in this case) supports C++11 syntax.

Does Qt Creator support C?

In addition, the Qt Creator Bare Metal Device plugin provides support for the following compilers: IAREW is a group of C and C++ bare-metal compilers from the various IAR Embedded Workbench development environments. Note: Currently supported architectures are 8051 , AVR , ARM , STM8 , and MSP430 .

Does Qt support C ++ 17?

As mentioned, Qt 6 makes C++17 a requirement in order to adopt its more advanced language features.

Does Qt support C ++ 14?

No, C++17 standard contains C++14 already... FYI: Clang that's at least the one you use for the precompiled Qt libs. FYI: Clang that's at least the one you use for the precompiled Qt libs. While true, Qt officially only supports the clang version provided through Xcode.


According to this site add

CONFIG += c++11

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


The other answers, suggesting

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

also work with Qt 4.8 and gcc / clang.


Add this to your .pro file

QMAKE_CXXFLAGS += -std=c++11

or

CONFIG += c++11

As an alternative for handling both cases addressed in Ali's excellent answer, I usually add

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

to my project files. This can be handy when you don't really care much about which Qt version is people using in your team, but you want them to have C++11 enabled in any case.


add to your qmake file

QMAKE_CXXFLAGS+= -std=c++11
QMAKE_LFLAGS +=  -std=c++11

If you are using an earlier version of QT (<5) try this

QMAKE_CXXFLAGS += -std=c++0x