I am developing a Qt 4.8 application using QGraphicsScene on Windows XP. When the user double clicks on a QGraphicsTextItem, i call
textItem->setTextInteractionFlags(Qt::TextEditorInteraction);
At the next selection change i call
textItem->setTextInteractionFlags(Qt::NoTextInteraction);
This works correctly, but i find no way to remove the inversion of the background color that remains from editing. In the screen shot below, i first double clicked on the first text item and selected the characters "2927". Then i clicked on the second test item and selected "est". I find no way to get rid of the still inverted "2927" in the first text item (although its not in edit mode anymore).
I also tried to call:
textItem->textCursor().clearSelection();
textItem->update();
textItem->setTextInteractionFlags(Qt::NoTextInteraction);
textItem->clearFocus();
But his does not at all change the behavior.
So now i found a workaround:
QString s = textItem->toPlainText();
textItem->setPlainText("");
textItem->setPlainText(s);
textItem->setTextInteractionFlags(Qt::NoTextInteraction);
I dont like that, but it works.
Any hint for a cleaner solution?