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.
  • jbcppJ Offline
    jbcppJ Offline
    jbcpp
    wrote on last edited by jbcpp
    #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
    • jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on 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

      jbcppJ 1 Reply Last reply
      0
      • jsulmJ jsulm

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

        jbcppJ Offline
        jbcppJ Offline
        jbcpp
        wrote on last edited by
        #3

        @jsulm Yes.

        1 Reply Last reply
        0
        • jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on 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

          jbcppJ 1 Reply Last reply
          0
          • jsulmJ jsulm

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

            jbcppJ Offline
            jbcppJ Offline
            jbcpp
            wrote on 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
            • jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              You can use the VS2015 Community edition + Qt 5.6

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

              jbcppJ 1 Reply Last reply
              0
              • hskoglundH Offline
                hskoglundH Offline
                hskoglund
                wrote on last edited by
                #7

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

                1 Reply Last reply
                0
                • jsulmJ jsulm

                  You can use the VS2015 Community edition + Qt 5.6

                  jbcppJ Offline
                  jbcppJ Offline
                  jbcpp
                  wrote on last edited by
                  #8

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

                  jsulmJ 1 Reply Last reply
                  0
                  • jbcppJ jbcpp

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

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on 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

                    • Login

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