Qt Snippet: Remove all rows from QTableWidget


QTableWidget is the Qt widget that, as the name suggest, show a table composed by cells able to contain both native field like text or icon and also more complex widgets like listbox, checkbox and so on.




Usually for Qt list widgets the method clear() remove all the rows currently showed in the control. However, also if present, this call doesn't work for QTableWidget control. If you want to remove all the rows from QTableWidget you need to simply set the number of rows to zero as follow:

MyTable->setRowCount(0);

This will have same effect of clear() and remove all rows.

0 Comments:

Post a Comment