QInputEvent Class
QInputEvent 类是描述用户输入的事件的基类。更多
头文件: | #include <QInputEvent> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Gui) target_link_libraries(mytarget PRIVATE Qt6::Gui) |
qmake: | QT += gui |
继承: | QEvent |
继承于 |
- 所有成员的列表,包括继承成员
- QInputEvent 属于事件类。
公共函数
(since 6.0) const QInputDevice * | device() const |
QInputDevice::DeviceType | deviceType() const |
Qt::KeyboardModifiers | modifiers() const |
quint64 | timestamp() const |
成员函数文档
[since 6.0]
const QInputDevice *QInputEvent::device() const
返回生成原始事件的源设备。
如果是合成事件,例如从触摸事件生成的鼠标事件,device()
将继续返回触摸屏设备,这样您就可以知道该事件并非来自实际的鼠标。因此,mouseEvent.source()->type() != QInputDevice::DeviceType::Mouse
是 Qt XML 5 表达式mouseEvent.source() == Qt::MouseEventSynthesizedByQt
的一种可能替代方式。
该函数在 Qt 6.0 中引入。
另请参阅 QPointerEvent::pointingDevice()。
QInputDevice::DeviceType QInputEvent::deviceType() const
返回生成事件的设备类型。
Qt::KeyboardModifiers QInputEvent::modifiers() const
返回事件发生前的键盘修改器标志。
另请参阅 QGuiApplication::keyboardModifiers()。
quint64 QInputEvent::timestamp() 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.