markusho
10th March 2010, 12:52
I am working on a GUI to display log messages. For this I use a QTableView and a model that inherits from QAbstractTableModel. Each row in the QTableView represents one message. Due to the fact that some messages contain more text than others I have to resize the row height depending on the text length. For this I set the following:
tableView->setWordWrap(true);
tableView->setTextElideMode(Qt::ElideNone);
tableView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
This works so far. The problem is a performance issue. If I insert one item the sizeHint role is called for all rows (and their columns) in the model - not only for the ones that are visible.
Is there a way to get QT calculate sizes of visible rows only ?
After inserting a new row into the model i called "reset()" in a first version. In my newest version I use "beginInsertRows()" and "endInsertRows()" instead but anyway the sizeHints of all model elements is requested by the view.
tableView->setWordWrap(true);
tableView->setTextElideMode(Qt::ElideNone);
tableView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
This works so far. The problem is a performance issue. If I insert one item the sizeHint role is called for all rows (and their columns) in the model - not only for the ones that are visible.
Is there a way to get QT calculate sizes of visible rows only ?
After inserting a new row into the model i called "reset()" in a first version. In my newest version I use "beginInsertRows()" and "endInsertRows()" instead but anyway the sizeHints of all model elements is requested by the view.