Вопрос

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();
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top