"Non-aggregates cannot be initialized with initializer list."
-
wrote on 1 Apr 2016, 11:56 last edited by jbcpp 4 Jan 2016, 12:05
I'm currently using the QT creator IDE to try and learn C++. When I run the following code:
#include <iostream> #include <string> #include <vector> using namespace std; int main(int argc, char *argv[]) { vector <int> theVector = {1, 2, 3, 4, 5}; cout << theVector[0]; }
When I run this I get the error from the post title. I have tried adding 'CONFIG += c++11' & 'CONFIG += c++14' to my .pro file to no avail.
Here are some relevant screenshots:
https://imgur.com/lkot7pV - this is my .pro file. I then press rebuild and then run qmake once I type in the config lines.
https://imgur.com/Bt34bcy - this is what version of QT creator I'm using.I'm using the non-QT C++ console application project type. I'm using the qmake build system. The build kits are: Desktop QT 5.4.2 MSVC2012 OpenGL 32-bit and Desktop QT 5.5.1 MSVC2012 32 bit. Any help is appreciated.
-
Did you rerun qmake after adding CONFIG += c++11 and before rebuild ?
-
Maybe MSVC2012 does not support this?
Here on Ubuntu with GCC 4.8.4 it is working. -
You can use the VS2015 Community edition + Qt 5.6
-
wrote on 1 Apr 2016, 12:37 last edited by
Hi, also you can use VS2013 Community edition + Qt 5.5.x
-
@jbcpp You need VS2015 and Qt 5.6 for VS2015. After installing VS2015 just use the online installer for Qt to install Qt.
1/9