本文整理汇总了C++中QWidgetAction::setParent方法的典型用法代码示例。如果您正苦于以下问题:C++ QWidgetAction::setParent方法的具体用法?C++ QWidgetAction::setParent怎么用?C++ QWidgetAction::setParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWidgetAction
的用法示例。
在下文中一共展示了QWidgetAction::setParent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: actionEvent
/*! \reimp */
void QToolBar::actionEvent(QActionEvent *event)
{
Q_D(QToolBar);
QAction *action = event->action();
QWidgetAction *widgetAction = qobject_cast<QWidgetAction *>(action);
switch (event->type()) {
case QEvent::ActionAdded: {
Q_ASSERT_X(widgetAction == 0 || d->layout->indexOf(widgetAction) == -1,
"QToolBar", "widgets cannot be inserted multiple times");
// reparent the action to this toolbar if it has been created
// using the addAction(text) etc. convenience functions, to
// preserve Qt 4.1.x behavior. The widget is already
// reparented to us due to the createWidget call inside
// createItem()
if (widgetAction != 0 && widgetAction->d_func()->autoCreated)
widgetAction->setParent(this);
int index = d->layout->count();
if (event->before()) {
index = d->layout->indexOf(event->before());
Q_ASSERT_X(index != -1, "QToolBar::insertAction", "internal error");
}
d->layout->insertAction(index, action);
break;
}
case QEvent::ActionChanged:
d->layout->invalidate();
break;
case QEvent::ActionRemoved: {
int index = d->layout->indexOf(action);
if (index != -1) {
delete d->layout->takeAt(index);
}
break;
}
default:
Q_ASSERT_X(false, "QToolBar::actionEvent", "internal error");
}
}