Qt World Summit: Register Today!

How to use C++11 in QtCreator 2.4.1?

  • I did some searches and found that people suggesting adding this flag to the .pro file.

    @QMAKE_CXXFLAGS += -std=c++0x@

    Unfortunately it doesn't seem to make any difference, any idea?

  • Qt Creator 2.4.1 has very limited support for C++0x itself. So you will get strange effects in the UI when using C++0x. None of the CXXFLAGS will change anything there.

    What this flag does is to instruct the compiler used by Creator to accept C++0x code. I am not sure how portable this is between compilers, so you might want to only add this flags to gcc based compilers:-)

  • Hi Tobias,

    Thanks for your quick response. If C++0x isn't supported in Qt 2.4.1, then do you know what future version will fully support it?
    By the way, Qt4 framework is just brilliant. I'm been learning for 3 days and fell deeply in love with it ;)

  • On a side note, besides newer version of creator you will need a newer version of GCC, since the compiler, shipping with Qt is a rather ancient version with very limited c++11 support. Or alternatively, use it with the MSVC compiler, although GCC 4.7+ has significantly better c++11 feature support, but for MSVC you have precompiled libraries.

Log in to reply