There is no clue in the documentation, but this appears to work:
textItem->setFocus();
Вопрос
In my code I create a QGraphicsTextItem
which has the editing flag on.
I want to find a way to make it focused in a way that it shows the caret and allows the user to type — just like when the user clicks on it but from code.
Is there any way to perform this programmatically?
The closest I found is textItem->grabKeyboad()
, which allows the user to write but does not show the dashed border and the caret is not shown until a key is pressed (no visual clue).
Решение
There is no clue in the documentation, but this appears to work:
textItem->setFocus();