Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Error when initializing QStringList using initializer list.
Forum Updated to NodeBB v4.3 + New Features

Error when initializing QStringList using initializer list.

Scheduled Pinned Locked Moved Installation and Deployment
11 Posts 3 Posters 14.8k Views 1 Watching
  • 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.
  • M Offline
    M Offline
    Mahima
    wrote on last edited by
    #1

    Hi,

    I am using Qt 5.3.1 and Visual studio 2013. When I am initializing QStringList using initializer list then it is giving error.
    For ex. When I am doing this :

    QStringList {'a', 'b' , 'c'}; then I am getting following error:

    error C2440: '<function-style-cast>' : cannot convert from 'initializer-list' to 'QStringList'.

    It was working fine with Qt 5.2.

    Do any one is having idea about this?

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      Not sure but can you recompile with c++11 flag enabled.
      Add this to your .pro file
      @
      CONFIG += c++11
      @

      157

      1 Reply Last reply
      0
      • JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote on last edited by
        #3

        Hi,

        Unfortunately Qt doesn't define a macro required to support initializer lists in MSVC 2013. Please add your vote to https://bugreports.qt-project.org/browse/QTBUG-39142 to have it fixed.

        As a temporary workaround, add this line to your .pro file and rerun qmake:
        @
        DEFINES += Q_COMPILER_INITIALIZER_LISTS
        @

        (Note: Be careful not to use this workaround if you have a compiler that doesn't support initializer lists)

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        1 Reply Last reply
        1
        • M Offline
          M Offline
          Mahima
          wrote on last edited by
          #4

          Ok.

          Thanks a lot.

          Maahi

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Mahima
            wrote on last edited by
            #5

            Hi,

            I tried but still its not working.
            Which .pro file needs to be changed ?

            Thanks,
            Maahi

            1 Reply Last reply
            0
            • JKSHJ Offline
              JKSHJ Offline
              JKSH
              Moderators
              wrote on last edited by
              #6

              Did you rerun qmake?

              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

              1 Reply Last reply
              0
              • M Offline
                M Offline
                Mahima
                wrote on last edited by
                #7

                Yes, I followed the step.

                But there are a lot of .pro files. For ex. qt.pro , qtbase.pro. I made changes and configured again and run nmake. he whole process which I follow to build Qt binaries. Still it failed.

                Thanks
                Maahi

                1 Reply Last reply
                0
                • JKSHJ Offline
                  JKSHJ Offline
                  JKSH
                  Moderators
                  wrote on last edited by
                  #8

                  Ah, I meant the .pro file of your project! You didn't need to recompile the Qt binaries. Sorry I wasn't clear before...

                  Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    Mahima
                    wrote on last edited by
                    #9

                    Ok.
                    The confusion is there becos there is no .pro file of my project. We use visual studio 2013 as compiler and use Qt (to support multi platform) integrated in it. So I configured Qt binaries for VS 2013. There was no problem when used Qt 5.2 but with Qt 5.3 there are issues (as mentioned in the link).

                    That's why I reconfigured Qt. Do you have any idea ?

                    Thanks,
                    Maahi

                    1 Reply Last reply
                    0
                    • JKSHJ Offline
                      JKSHJ Offline
                      JKSH
                      Moderators
                      wrote on last edited by
                      #10

                      Ok.

                      • Use your original copy of Qt (before you reconfigured it)
                      • Define the "Q_COMPILER_INITIALIZER_LISTS" in your project configuration. (I'm not sure how Visual Studio does that)

                      As long as that macro is defined BEFORE any Qt headers are included, you can use initializer lists.

                      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        Mahima
                        wrote on last edited by
                        #11

                        Thanks.

                        Maahi

                        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