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. How can I set QTableWidget row index from 64 to 127 instead of from 0 to 63
Forum Updated to NodeBB v4.3 + New Features

How can I set QTableWidget row index from 64 to 127 instead of from 0 to 63

Scheduled Pinned Locked Moved General and Desktop
9 Posts 5 Posters 6.5k 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.
  • B Offline
    B Offline
    Beoborg
    wrote on last edited by
    #1

    The problem is that I have struct vector of 128 items. I should put first 64 items to first QTableWidget and remaining 64 items to second QTableWidget. It is essential to show "index" numbers as they are in my struct vector. Those are Id numbers. I have designed my ui using UI designer, I tried to change QTableWidget First row number there, but it didn't work. How can I initialize tablewidget which index starts with 0 -> and tablewidget which index starts from 64 -> ??

    1 Reply Last reply
    0
    • D Offline
      D Offline
      deepakberiwal
      wrote on last edited by
      #2

      Did u get some solution for this? I also want to implement the same thing. Please let me know if you have any idea how to proceed.

      1 Reply Last reply
      0
      • B Offline
        B Offline
        Beoborg
        wrote on last edited by
        #3

        I haven't found solution yet, but if I do I will post it here.

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          What about the "vertical header labels":http://qt-project.org/doc/qt-4.8/qtablewidget.html#setVerticalHeaderLabels?

          (Z(:^

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tobias.hunger
            wrote on last edited by
            #5

            I guess you could use a Proxy model to "move" the indexes used by the view over.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              Macro
              wrote on last edited by
              #6

              Thanks Sierdzio for your help..... :)

              1 Reply Last reply
              0
              • sierdzioS Offline
                sierdzioS Offline
                sierdzio
                Moderators
                wrote on last edited by
                #7

                No worries. Better tell me if it worked :-)

                (Z(:^

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  Macro
                  wrote on last edited by
                  #8

                  Yeah it works fine sierdzio... Sorry for the delay in responding back...

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

                    I Think, using setHeaderData itself we can change the Index Id of the TableView.

                    Here's my Piece of Coding...

                    @int main(int argc, char *argv[])
                    {
                    QApplication app(argc, argv);

                    QStandardItemModel model(64, 2);
                    int row;
                    int column;
                    int rowCount = model.rowCount();
                    int columnCount = model.columnCount();
                    for (row = 0; row < rowCount; ++row)
                    {
                        for (column = 0; column < columnCount; ++column)
                        {
                            QStandardItem *item = new QStandardItem (QString("row %0, column %1").arg(row).arg(column));
                            model.setItem(row, column, item);
                        }
                    }
                    
                    // change before display
                    
                    for(int i =0; i < rowCount; i++)
                    {
                        int indexId = 65+i;
                        model.setHeaderData(i, Qt::Vertical, indexId);
                    }
                    
                    View v;
                    v.setModel(&model);
                    v.show();
                    
                    return app.exec();
                    

                    }@

                    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