本文整理汇总了C++中QWidgetAction::d_func方法的典型用法代码示例。如果您正苦于以下问题:C++ QWidgetAction::d_func方法的具体用法?C++ QWidgetAction::d_func怎么用?C++ QWidgetAction::d_func使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWidgetAction
的用法示例。
在下文中一共展示了QWidgetAction::d_func方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addWidget
/*!
Inserts the given \a widget in front of the toolbar item
associated with the \a before action.
Note: You should use QAction::setVisible() to change the
visibility of the widget. Using QWidget::setVisible(),
QWidget::show() and QWidget::hide() does not work.
\sa addWidget()
*/
QAction *QToolBar::insertWidget(QAction *before, QWidget *widget)
{
QWidgetAction *action = new QWidgetAction(this);
action->setDefaultWidget(widget);
action->d_func()->autoCreated = true;
insertAction(before, action);
return action;
}
示例2: insertWidget
/*!
Adds the given \a widget to the toolbar as the toolbar's last
item.
The toolbar takes ownership of \a widget.
If you add a QToolButton with this method, the tools bar's
Qt::ToolButtonStyle will not be respected.
\note You should use QAction::setVisible() to change the
visibility of the widget. Using QWidget::setVisible(),
QWidget::show() and QWidget::hide() does not work.
\sa insertWidget()
*/
QAction *QToolBar::addWidget(QWidget *widget)
{
QWidgetAction *action = new QWidgetAction(this);
action->setDefaultWidget(widget);
action->d_func()->autoCreated = true;
addAction(action);
return action;
}
示例3: 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");
}
}