QActionEvent Class
QActionEvent 类提供了在添加、删除或更改QAction 时生成的事件。更多
头文件: | #include <QActionEvent> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Gui) target_link_libraries(mytarget PRIVATE Qt6::Gui) |
qmake: | QT += gui |
继承: | QEvent |
- 所有成员(包括继承成员)的列表
- QActionEvent 属于事件类。
公共函数
QActionEvent(int type, QAction *action, QAction *before = nullptr) | |
QAction * | action() const |
QAction * | before() const |
详细说明
例如,可以通过使用QWidget::addAction() 将动作添加到控件中。这会生成一个ActionAdded 事件,您可以处理该事件以提供自定义行为。例如,QToolBar 对QWidget::actionEvent() 进行了重新实现,为操作创建了QToolButtons。
另请参阅 QAction,QWidget::addAction(),QWidget::removeAction() 和QWidget::actions() 。
成员函数文档
QActionEvent::QActionEvent(int type, QAction *action, QAction *before = nullptr)
构造一个动作事件。type 可以是ActionChanged 、ActionAdded 或ActionRemoved 。
action 是要更改、添加或删除的操作。如果 是 ActionAdded,则该操作将插入到操作 之前。如果 是 ,则该操作将被附加。type before before nullptr
QAction *QActionEvent::action() const
返回已更改、添加或删除的操作。
另请参阅 before()。
QAction *QActionEvent::before() const
如果type() 是ActionAdded ,则返回应出现在action() 之前的操作。如果此函数返回nullptr
,则该操作应附加到同一 widget 上已有的操作中。
另请参阅 action() 和QWidget::actions()。
© 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.