开发者

Setting button focus in a graphcisview

开发者 https://www.devze.com 2023-01-08 07:47 出处:网络
I have placed a few buttons in a Qgraphicsscene, but I don’t know how to navigate to the button from a keyboard.

I have placed a few buttons in a Qgraphicsscene, but I don’t know how to navigate to the button from a keyboard.

How would I set the focus to a button from the keyboard?开发者_如何学JAVA


I assume that you used QGraphicsScene::addWidget() to add the button to the scene? It gives you a proxy object back, QGraphicsProxyWidget *, which inherits QGraphicsItem::setFocus(). But remember that it needs to have set the ItemIsFocusable flag and needs to be visible and active as well.

Additionally (from the setFocus() documentation):

As a result of calling this function, this item will receive a focus in event with focusReason. If another item already has focus, that item will first receive a focus out event indicating that it has lost input focus.

0

精彩评论

暂无评论...
验证码 换一张
取 消