title: How to Program C++11 Using Qt5?
body: <p>I'm getting ready to program a cross-platform project with my friend. We decided on using Qt and gcc as our IDE and toolchain respectively. He works on Linux, I work on Windows. </p>
  
  <p>However, gcc on Linux isn't necessarily gcc on Windows. More specifically, Qt on Windows installs mingw with gcc 4.4  and my friend has gcc 4.7. So I tried getting a more recent gcc version for windows.</p>
  
  <p>My current version of Qt is 5 and using gcc 4.7 downloaded and installed from this site: <a href="http://www.equation.com/servlet/equation.cmd?fa=fortran" rel="noreferrer">http://www.equation.com/servlet/equation.cmd?fa=fortran</a></p>
  
  <p>I installed it in C:\QtSDK\mingw  and simply overrode all the files existing from the Qt installation. I figured that I wouldn't have to reconfigure anything in Qt if I just took the short route.</p>
  
  <p>However, even using the compiler flags:</p>
  
  <pre><code>QMAKE_CXXFLAGS += -std=c++0x (Qt 4.7)
  </code></pre>
  
  <p>and</p>
  
  <pre><code>CONFIG   += c++11 (Qt5)
  </code></pre>
  
  <p>the IDE or toolchain fails to compile a simple range-based for loop:</p>
  
  <pre><code>int main(int argc, char *argv[])
  {
      int my_array[5] = {1, 2, 3, 4, 5};
      for (auto x : my_array)
          std::cout &lt;&lt; x &lt;&lt; std::endl;
  
      return 0;
  }
  </code></pre>
  
  <p>or initializer-lists:</p>
  
  <pre><code>int main(int argc, char *argv[])
  {
      QVector&lt;int&gt; testsData { 1, 2, 10, 42, 50, 123  };
      QStringList options = { QLatin1String("foo"), QLatin1String("bar")  };
  
      return 0;
  }
  </code></pre>
  
  <p>However, looking at the implementation details of gcc 4.7, both of these features- and more- should be readily available. </p>
  
  <p>Has anyone else tried to use gcc and Qt for Windows? If so, how did you get it to work? I would like a solution using gcc 4.6 or 4.7, but will settle for less if it is not at all possible.</p>
  
  <p>Alternatively, is there a dev environment for Linux and Windows that makes use of C++11 features? I would also settle for something besides Qt if it just works...</p>
  
  <p>I used the sources:</p>
  
  <p><a href="http://labs.qt.nokia.com/2011/05/26/cpp0x-in-qt/" rel="noreferrer">C++0x in Qt (Qt 4.7-4.8)</a></p>
  
  <p><a href="http://woboq.com/blog/cpp11-in-qt5.html" rel="noreferrer">C++11 in Qt5</a></p>