QFocusEvent Class
QFocusEvent 类包含部件焦点事件的事件参数。更多
头文件: | #include <QFocusEvent> |
CMake.QFocusEvent | find_package(Qt6 REQUIRED COMPONENTS Gui) target_link_libraries(mytarget PRIVATE Qt6::Gui) |
qmake: | QT += gui |
继承: | QEvent |
- 所有成员(包括继承成员)的列表
- QFocusEvent 属于事件类。
公共函数
QFocusEvent(QEvent::Type type, Qt::FocusReason reason = Qt::OtherFocusReason) | |
bool | gotFocus() const |
bool | lostFocus() const |
Qt::FocusReason | reason() const |
详细说明
当键盘输入焦点发生变化时,焦点事件会被发送到部件。焦点事件发生的原因包括鼠标操作、按键(如Tab 或Backtab )、窗口系统、弹出菜单、键盘快捷键或其他应用程序特定的原因。reason() 会在相应的事件处理程序中返回特定焦点事件的原因。
事件处理程序QWidget::focusInEvent(),QWidget::focusOutEvent(),QGraphicsItem::focusInEvent 和QGraphicsItem::focusOutEvent() 接收焦点事件。
另请参阅 QWidget::setFocus(),QWidget::setFocusPolicy() 和小工具中的键盘焦点。
成员函数文档
[explicit]
QFocusEvent::QFocusEvent(QEvent::Type type, Qt::FocusReason reason = Qt::OtherFocusReason)
构造焦点事件对象。
type 参数必须是QEvent::FocusIn 或QEvent::FocusOut 。reason 描述焦点变化的原因。
bool QFocusEvent::gotFocus() const
如果type() 是QEvent::FocusIn ,则返回true
;否则返回 false。
bool QFocusEvent::lostFocus() const
如果type() 是QEvent::FocusOut ,则返回true
;否则返回 false。
Qt::FocusReason QFocusEvent::reason() const
返回此聚焦事件的原因。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.