PDA

View Full Version : [QTableWidget] clearing a big table takes so long!



punkypogo
4th August 2010, 10:08
Hello,

I have a QTableWidget which owns 640*480 QTableWidgetItems.
When I make a clearContents() on it, it takes several seconds to do it. Is there any way to empty the table faster?

Thank you.

Lykurg
4th August 2010, 10:19
640*480 are 307200 items! You really should consider using a model. And there is no faster way, only create a new table widget and remove the items in background.

punkypogo
4th August 2010, 10:52
I know this is really huge. Do you think using a model will increase performance?

Lykurg
4th August 2010, 10:58
Well, a QStandardItemModel surely not, but if use e.g. a SQL** model (or a custom one) then yes, because no items (=disk memory) need to be removed etc. Just set up a database with 30.000.000 items and display them using a QSqlTableModel and see how fast it is "cleared".

punkypogo
5th August 2010, 13:52
I just implemented with QAbstractTableModel, and wow! This is incredibly fast compared to QTableWidget!

Thanks a lot for your answer!
Cheers.