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<mystruct> access
Forum Updated to NodeBB v4.3 + New Features

QVector<mystruct> access

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 278 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.
  • gfxxG Offline
    gfxxG Offline
    gfxx
    wrote on last edited by gfxx
    #1

    my mainwindows.h ..

    typedef struct{
    int a[12] = {}
    QString b[12] = {}
    int a1[12] = {}
    QString b1[12] = {}
    } mystruct
    

    my mainwindows.cpp ...

    QVector<mystruct *> mys(10);
    
    ..... /* insert data in struct for 10 Qvec */
    
    void Mainwindow::call(){
    int babe = mys[1]->a[2].value();
    }
    
    

    these is admitted or there are a best solution for? I need to have a QVector of container with an array of some mixed var type (int, qstring, double) ..... so think to declare a struct with array value .... but maybe not well done ... not experience on these things ...

    regards

    bkt

    jsulmJ 1 Reply Last reply
    0
    • gfxxG gfxx

      @jsulm just re-edit the question .... thanks .... so you think about QVector<Qvector<mystruct>> mst; ?? without array on struct? or in mainwindows.h ...

      typedef struct{
      int a;
      QString b;
      int a1;
      QString b1;
      } mystruct
      

      than ..

      QVector<QVector<mystruct >> mys(10);
      
      ..... /* insert data in struct for 10 Qvec */
      
      void Mainwindow::call(){
      int babe = mys[1].[2]a.value();
      
      

      you means these? Is well write?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #4

      @gfxx said in QVector<mystruct> access:

      you means these?

      No, I did not mean this.
      What I mean is simply:

      QVector<mystruct> mys(10);
      

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

      1 Reply Last reply
      2
      • gfxxG gfxx

        my mainwindows.h ..

        typedef struct{
        int a[12] = {}
        QString b[12] = {}
        int a1[12] = {}
        QString b1[12] = {}
        } mystruct
        

        my mainwindows.cpp ...

        QVector<mystruct *> mys(10);
        
        ..... /* insert data in struct for 10 Qvec */
        
        void Mainwindow::call(){
        int babe = mys[1]->a[2].value();
        }
        
        

        these is admitted or there are a best solution for? I need to have a QVector of container with an array of some mixed var type (int, qstring, double) ..... so think to declare a struct with array value .... but maybe not well done ... not experience on these things ...

        regards

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @gfxx said in QVector<mystruct> access:

        these is admitted or there are a best solution for?

        I don't understand the question. Can you explain?
        You could also store mystruct directly in the vector instead of pointers.

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

        gfxxG 1 Reply Last reply
        0
        • jsulmJ jsulm

          @gfxx said in QVector<mystruct> access:

          these is admitted or there are a best solution for?

          I don't understand the question. Can you explain?
          You could also store mystruct directly in the vector instead of pointers.

          gfxxG Offline
          gfxxG Offline
          gfxx
          wrote on last edited by gfxx
          #3

          @jsulm just re-edit the question .... thanks .... so you think about QVector<Qvector<mystruct>> mst; ?? without array on struct? or in mainwindows.h ...

          typedef struct{
          int a;
          QString b;
          int a1;
          QString b1;
          } mystruct
          

          than ..

          QVector<QVector<mystruct >> mys(10);
          
          ..... /* insert data in struct for 10 Qvec */
          
          void Mainwindow::call(){
          int babe = mys[1].[2]a.value();
          
          

          you means these? Is well write?

          bkt

          jsulmJ 1 Reply Last reply
          0
          • gfxxG gfxx

            @jsulm just re-edit the question .... thanks .... so you think about QVector<Qvector<mystruct>> mst; ?? without array on struct? or in mainwindows.h ...

            typedef struct{
            int a;
            QString b;
            int a1;
            QString b1;
            } mystruct
            

            than ..

            QVector<QVector<mystruct >> mys(10);
            
            ..... /* insert data in struct for 10 Qvec */
            
            void Mainwindow::call(){
            int babe = mys[1].[2]a.value();
            
            

            you means these? Is well write?

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #4

            @gfxx said in QVector<mystruct> access:

            you means these?

            No, I did not mean this.
            What I mean is simply:

            QVector<mystruct> mys(10);
            

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

            1 Reply Last reply
            2
            • gfxxG gfxx has marked this topic as solved on

            • Login

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