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. QVector

QVector

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 964 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.
  • V Offline
    V Offline
    veysel.olgun
    wrote on last edited by veysel.olgun
    #1

    hello,

    QVector <int> a;
     a << 20 << 30 << 40 << 50;
    

    error message : a does not name a type
    why i am getting this error message how can i solve it ?

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by dheerendra
      #2

      It should not. Show your complete program or try with just main.cpp. It should work. Did you #include <QVector>

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • V Offline
        V Offline
        veysel.olgun
        wrote on last edited by
        #3

        0_1543072485492_13bfb74e-5232-4e07-ac2f-fb3ad9f40ded-image.png

        i added #include<QVector>;

        aha_1980A 1 Reply Last reply
        0
        • V veysel.olgun

          0_1543072485492_13bfb74e-5232-4e07-ac2f-fb3ad9f40ded-image.png

          i added #include<QVector>;

          aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @veysel.olgun you cannot do this outside a function. try placing your code onside a fuction.

          Qt has to stay free or it will die.

          1 Reply Last reply
          1
          • dheerendraD Offline
            dheerendraD Offline
            dheerendra
            Qt Champions 2022
            wrote on last edited by
            #5

            hmm. You cannot execute the statement at global declaration. You are trying to execute the function outside. Only variable can be declared globally. Rest you have to do inside the code.

            e.g

            QVector<int> a;
            
            int main(int argc, char *argv[])
            {
                a << 10;
            }
            

            Dheerendra
            @Community Service
            Certified Qt Specialist
            http://www.pthinks.com

            1 Reply Last reply
            1
            • V Offline
              V Offline
              veysel.olgun
              wrote on last edited by
              #6

              i understand now thank you all, i fixed up the problem with your help

              1 Reply Last reply
              0
              • V Offline
                V Offline
                veysel.olgun
                wrote on last edited by
                #7

                0_1543073629161_a9fca6f9-c3bf-4bad-87f1-5cf803f1872c-image.png

                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