Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
SetExtraSelections in QGraphicsTextItem
mkuettler last edited by
I want to implement a text search for a QGraphicsTextItem. I have no problem with the search itself, but I have not yet found a good way to highlight the search results.
QTextEdit has the handy function setExtraSelections that would be perfect for this purpose. As QTextEdit just delegates the call to QTextControl::setExtraSelections, I see no reason why this feature should not be available in QGraphicsTextItem. Unfortunately QGraphicsTextItem makes a lot of features of QTextControl inaccessible to the user, including this one.
I considered using QTextLayout::setAdditionalFormats but this would mess with syntax highlighting.
I would appreciate any comments or suggestions to this problem.