QFocusEvent Class
QFocusEvent 类包含用于小部件焦点事件的事件参数。更多内容...
| 头文件: | #include <QFocusEvent> |
| CMake: | 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 |
受保护函数
| QFocusEvent(QFocusEvent &&) | |
| QFocusEvent & | operator=(QFocusEvent &&) |
| QFocusEvent & | operator=(const QFocusEvent &other) |
详细说明
当键盘输入焦点发生变化时,焦点事件会发送给小部件。焦点事件可能由鼠标操作、按键(例如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 描述了焦点变化的原因。
[protected delete] QFocusEvent::QFocusEvent(QFocusEvent &&)
通过移动构造一个QFocusEvent 的实例。该函数已被删除。
bool QFocusEvent::gotFocus() const
如果type()的结果是QEvent::FocusIn ,则返回true ;否则返回false。
bool QFocusEvent::lostFocus() const
如果type()的值为QEvent::FocusOut ,则返回true ;否则返回false。
Qt::FocusReason QFocusEvent::reason() const
返回此焦点事件的原因。
[protected delete] QFocusEvent &QFocusEvent::operator=(QFocusEvent &&)
将other 按移动赋值给此QFocusEvent 实例。该函数已被删除。
[noexcept protected default] QFocusEvent &QFocusEvent::operator=(const QFocusEvent &other)
将other 复制并赋值给此QFocusEvent 实例。
© 2026 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.