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. [SOLVED]How to store data present in the tableview in any 2D array ?
QtWS25 Last Chance

[SOLVED]How to store data present in the tableview in any 2D array ?

Scheduled Pinned Locked Moved General and Desktop
qtableviewarraydata
9 Posts 2 Posters 3.8k 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.
  • RatzzR Offline
    RatzzR Offline
    Ratzz
    wrote on last edited by Ratzz
    #1

    I have a tableview which is contains 32 rows and 32 column . Each cell is a comboboxdelegate (each cell is a combobox) which contains several items in the list. User has the ability to change the values of comboboxdelegate .I have a radiobutton "Tx" and "Rx" . on clicking "Tx"/"Rx" the tableview should display the values which was selected by the user for Tx/Rx in the same tableview. I have to store the data for each of Tx/Rx in a 2D array and update the data as the user updates. On Tx/Rx radiobutton click i want to retrieve the value from 2D array and display it in the tableview .
    How to store data present in the tableview in any 2D array ? and how to retrieve the value from 2D array and display it in the tableview?

    --Alles ist gut.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You can build your own model on top of e.g. two QVector<QVector<whatever_type_you_need>> that you will switch when changing Tx/Rx

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • RatzzR Offline
        RatzzR Offline
        Ratzz
        wrote on last edited by
        #3

        @SGaist
        Hi.Thanks for the reply.
        How about storing values in Qstring ?

            QString TxDataTables[32][32];
            for(int row=0;row<32;row++)
            {
                for (int column=0;column<32;column++)
                {
                 QModelIndex index = DataTableModel->index(row, column, QModelIndex());
                 TxDataTables[row][column] = index.data().toString();
                }
            }
        

        how to retrieve the data when Tx/Rx changed ?

        --Alles ist gut.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Depends on whether you store both information in your strings or if you have two tables

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • RatzzR Offline
            RatzzR Offline
            Ratzz
            wrote on last edited by
            #5

            @SGaist
            I want to store the data in the string .

            --Alles ist gut.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Then you have to parse the string each time. Wouldn't it be more practical to use a QPair ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • RatzzR Offline
                RatzzR Offline
                Ratzz
                wrote on last edited by Ratzz
                #7

                @SGaist
                I have done it with the structure

                RTStruct *rtStruct;
                    for(int row=0;row<32;row++)
                    {
                        rtStruct = rtList.at(row);
                        for (int column=0;column<32;column++)
                        {
                       QModelIndex index = DataTableModel->index(row, column, QModelIndex());
                            if(addressArea == TX)
                            {
                                rtStruct->txDataTables[column] = index.data().toString();
                            }
                            else
                            {
                                rtStruct->rxDataTables[column] = index.data().toString();
                            }
                        }
                    }
                

                How to do it with Qpair?

                --Alles ist gut.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  If you already have a struct that fits your needs then no need to change anything

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  1
                  • RatzzR Offline
                    RatzzR Offline
                    Ratzz
                    wrote on last edited by
                    #9

                    @SGaist
                    Yes, It worked me out.

                    --Alles ist gut.

                    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