Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. "Non-aggregates cannot be initialized with initializer list."
QtWS25 Last Chance

"Non-aggregates cannot be initialized with initializer list."

Scheduled Pinned Locked Moved Unsolved General and Desktop
c++ qt
9 Posts 3 Posters 4.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jbcpp
    wrote on 1 Apr 2016, 11:56 last edited by jbcpp 4 Jan 2016, 12:05
    #1

    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.

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 1 Apr 2016, 12:20 last edited by
      #2

      Did you rerun qmake after adding CONFIG += c++11 and before rebuild ?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      J 1 Reply Last reply 1 Apr 2016, 12:21
      0
      • J jsulm
        1 Apr 2016, 12:20

        Did you rerun qmake after adding CONFIG += c++11 and before rebuild ?

        J Offline
        J Offline
        jbcpp
        wrote on 1 Apr 2016, 12:21 last edited by
        #3

        @jsulm Yes.

        1 Reply Last reply
        0
        • J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 1 Apr 2016, 12:22 last edited by
          #4

          Maybe MSVC2012 does not support this?
          Here on Ubuntu with GCC 4.8.4 it is working.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          J 1 Reply Last reply 1 Apr 2016, 12:27
          0
          • J jsulm
            1 Apr 2016, 12:22

            Maybe MSVC2012 does not support this?
            Here on Ubuntu with GCC 4.8.4 it is working.

            J Offline
            J Offline
            jbcpp
            wrote on 1 Apr 2016, 12:27 last edited by
            #5

            @jsulm I think that's right. I need a new compiler like mingw or something perhaps.

            1 Reply Last reply
            0
            • J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 1 Apr 2016, 12:32 last edited by
              #6

              You can use the VS2015 Community edition + Qt 5.6

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              J 1 Reply Last reply 1 Apr 2016, 13:33
              0
              • H Offline
                H Offline
                hskoglund
                wrote on 1 Apr 2016, 12:37 last edited by
                #7

                Hi, also you can use VS2013 Community edition + Qt 5.5.x

                1 Reply Last reply
                0
                • J jsulm
                  1 Apr 2016, 12:32

                  You can use the VS2015 Community edition + Qt 5.6

                  J Offline
                  J Offline
                  jbcpp
                  wrote on 1 Apr 2016, 13:33 last edited by
                  #8

                  @jsulm Do I just need to download VS2015 community edition for this to work?

                  J 1 Reply Last reply 4 Apr 2016, 04:12
                  0
                  • J jbcpp
                    1 Apr 2016, 13:33

                    @jsulm Do I just need to download VS2015 community edition for this to work?

                    J Offline
                    J Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on 4 Apr 2016, 04:12 last edited by
                    #9

                    @jbcpp You need VS2015 and Qt 5.6 for VS2015. After installing VS2015 just use the online installer for Qt to install Qt.

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0

                    9/9

                    4 Apr 2016, 04:12

                    • Login

                    • Login or register to search.
                    9 out of 9
                    • First post
                      9/9
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved