How can I set QTableWidget row index from 64 to 127 instead of from 0 to 63
-
wrote on 23 Oct 2012, 06:50 last edited by
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 -> ??
-
wrote on 23 Oct 2012, 07:33 last edited by
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.
-
wrote on 23 Oct 2012, 08:11 last edited by
I haven't found solution yet, but if I do I will post it here.
-
What about the "vertical header labels":http://qt-project.org/doc/qt-4.8/qtablewidget.html#setVerticalHeaderLabels?
-
wrote on 23 Oct 2012, 20:58 last edited by
I guess you could use a Proxy model to "move" the indexes used by the view over.
-
wrote on 24 Oct 2012, 07:17 last edited by
Thanks Sierdzio for your help..... :)
-
No worries. Better tell me if it worked :-)
-
wrote on 30 Oct 2012, 12:11 last edited by
Yeah it works fine sierdzio... Sorry for the delay in responding back...
-
wrote on 6 Nov 2012, 07:23 last edited by
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/9