문제

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