[Interest] Dynamically Resizing the height of a Row in a QTableWidget or QTableView

André Somers andre at familiesomers.nl
Tue Jun 26 11:43:51 CEST 2012


Op 25-6-2012 22:35, Michael Jackson schreef:
> Is it possible to dynamically set the row height based on the amount of text that needs to be displayed? We are trying to display some error messages in a table and some of the messages are very short (just a few words) and some of very long (lots and lots of words). Can this be done with a QTableWidget or should we move to a QTableView and custom model? Does anyone have any example code?
>
> Thanks
> ---
> Mike Jackson
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
Yes, that can be done. It does not matter if you use QTableView or 
QTableWidget (though I think the latter is big mistake to have in Qt): 
QTableWidget is based on QTableView, so it can do everything QTableView 
can do.

You can use the resizeRowToContents or resizeRowsToContents slots (note 
the singular vs plural of the 'row' noun in those method names.)

André



More information about the Interest mailing list