How can I set QTableWidget row index from 64 to 127 instead of from 0 to 63
-
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 -> ??
-
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.
-
What about the "vertical header labels":http://qt-project.org/doc/qt-4.8/qtablewidget.html#setVerticalHeaderLabels?
-
I guess you could use a Proxy model to "move" the indexes used by the view over.
-
No worries. Better tell me if it worked :-)
-
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();
}@