当前位置: 首页>>代码示例>>C++>>正文


C++ QWidgetAction::d_func方法代码示例

本文整理汇总了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;
}
开发者ID:dirlinch,项目名称:chromecast-mirrored-source.vendor,代码行数:18,代码来源:qtoolbar.cpp

示例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;
}
开发者ID:dirlinch,项目名称:chromecast-mirrored-source.vendor,代码行数:23,代码来源:qtoolbar.cpp

示例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");
    }
}
开发者ID:dirlinch,项目名称:chromecast-mirrored-source.vendor,代码行数:45,代码来源:qtoolbar.cpp


注:本文中的QWidgetAction::d_func方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。