QActionEvent 类

QActionEvent 类提供生成事件,当 QAction 被添加、被移除或被改变时。 更多...

头: #include <QActionEvent>
qmake: QT += gui
继承: QEvent

公共函数

QActionEvent (int type , QAction * action , QAction * before = nullptr)
QAction * action () const
QAction * before () const

详细描述

动作可以被添加到 Widget,使用 QWidget::addAction ()。这生成 ActionAdded 事件,可以处理这以提供自定义行为。例如, QToolBar 重实现 QWidget::actionEvent () 以创建 QToolButton 为动作。

另请参阅 QAction , QWidget::addAction (), QWidget::removeAction (),和 QWidget::actions ().

成员函数文档编制

QActionEvent:: QActionEvent ( int type , QAction * action , QAction * before = nullptr)

构造动作事件。 type 可以是 ActionChanged , ActionAdded ,或 ActionRemoved .

action 是被改变、被添加或被移除的动作。若 type is ActionAdded , the action is to be inserted before the action before 。若 before is nullptr ,追加动作。

QAction *QActionEvent:: action () const

返回被改变、被添加或被移除的动作。

另请参阅 before ().

QAction *QActionEvent:: before () const

type () 是 ActionAdded ,返回动作的出现应该前于 action ()。若此函数返回 nullptr ,动作应被追加到同一 Widget 已存在动作中。

另请参阅 action () 和 QWidget::actions ().