Qt setFocus

Qt  setFocus

参考资料:

https://doc.qt.io/qt-6/qwidget.html#setFocus

void QWidget::setFocus(Qt::FocusReason reason)
Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its parents is the active window. The reason argument will be passed into any focus event sent from this function, it is used to give an explanation of what caused the widget to get focus. If the window is not active, the widget will be given the focus when the window becomes active.

如果此部件或其父部件之一是活动窗口,则将键盘输入焦点赋予此部件(或其焦点代理)。reason参数将被传递到从该函数发送的任何焦点事件中,它用于解释是什么导致小部件获得焦点。如果窗口不是活动的,那么当窗口变为活动状态时,小部件将获得焦点。

First, a focus about to change event is sent to the focus widget (if any) to tell it that it is about to lose the focus. Then focus is changed, a focus out event is sent to the previous focus item and a focus in event is sent to the new item to tell it that it just received the focus. (Nothing happens if the focus in and focus out widgets are the same.)

首先,将焦点即将改变事件发送给焦点小部件(如果有的话),告诉它它即将失去焦点。然后焦点被更改,一个焦点out事件被发送给前一个焦点项,一个焦点in事件被发送给新项目,告诉它刚刚收到焦点。(如果焦点内和焦点外小部件是相同的,则不会发生任何事情。)

Note: On embedded platforms, setFocus() will not cause an input panel to be opened by the input method. If you want this to happen, you have to send a QEvent::RequestSoftwareInputPanel event to the widget yourself.

注意:在嵌入式平台上,setFocus()不会导致输入法打开一个输入面板。 如果你想要这个发生,你必须发送一个QEvent::RequestSoftwareInputPanel事件给小部件自己。 

setFocus() gives focus to a widget regardless of its focus policy, but does not clear any keyboard grab (see grabKeyboard()).

setFocus()将焦点赋予小部件,而不管它的焦点策略如何,但不清除任何键盘抓取(参见grabKeyboard())。 

Be aware that if the widget is hidden, it will not accept focus until it is shown.

请注意,如果小部件是隐藏的,它将不会接受焦点,直到显示出来。

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值