[Solved] Add new row to the QTableWidget to the top of the table?
-
Hi,
now I've got well working QTableWidget, but new rows are adding to the bootom of the table.
The only way I found is to sort rows by SortItems function. But I havn't got column that I should base.
This column is a number of the row, but it hasn't got an index.So can I add new row to the QTableWidget to the top of the table?
Thanks!
-
bq.
So can I add new row to the QTableWidget to the top of the table?"Top of the table" you mean at first position ?
Then you can do this with@
QTableWidget w;
w.insertRow(0);
@http://qt-project.org/doc/qt-4.8/qtablewidget.html#insertRow
You don't need to sort rows for this!!
-
Yes, you understand correctly.
Ok, I'm already add the first row insertRow(0), the second insertRow(1), the third insertRow(2) and else.
Or you mean that I should every row add with insertRow(0) and it won't reload, the old 0 row became 1 and the new row will be 0? -
Hi and welcome to devnet,
Exactly, insertRow(0) means that you want a new row at position 0 so if there's already one there, it will be moved to 1, 1 to 2 etc...
-
Thanks, It took me a day to find this answer.