Force repaint for a QTreeWidgetItem
I have written my own ItemDelegate to do some search highlighting in a QTreeWidget. When I set the string to be highlighted in the delegate, all the QTreeWidgetItems in a QTreeView shall be repainted (and highlighted if they match).
But when I call repaint() or update() on the QTreeWidget nothing happens. It is updated as soon as the mouse hovers it, but not before. I am in the UI thread, so this can not be the problem.
As a workaround, I have the following code:
for( int i = 0; i < treeWidget->topLevelItemCount(); ++i )
QTreeWidgetItem *item = treeWidget->topLevelItem( i );
QString text = item->text(0);
This causes a dataChanged() in the model and the items are repainted.
It seems to me that the TreeWidget is double buffered or something in like that and it only paints the existing buffer if nothing changed (i.e. a dataChanged() event from the model or scrolling or something like this).
Is there any better way to force a 'real' repaint?
Thanks a lot!