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


C++ QToolButton::actions方法代码示例

本文整理汇总了C++中QToolButton::actions方法的典型用法代码示例。如果您正苦于以下问题:C++ QToolButton::actions方法的具体用法?C++ QToolButton::actions怎么用?C++ QToolButton::actions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QToolButton的用法示例。


在下文中一共展示了QToolButton::actions方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: testRequestWidgetMenuModeWidgetParentSeveralActions

void KSelectAction_UnitTest::testRequestWidgetMenuModeWidgetParentSeveralActions()
{
    KSelectAction selectAction("selectAction", 0);
    selectAction.setToolBarMode(KSelectAction::MenuMode);

    selectAction.addAction(new QAction("action1", &selectAction));
    selectAction.addAction(new QAction("action2", &selectAction));
    selectAction.addAction(new QAction("action3", &selectAction));

    QToolBar toolBar;
    toolBar.addAction(&selectAction);
    QWidget* widget = toolBar.widgetForAction(&selectAction);

    QVERIFY(widget);
    QToolButton* toolButton = qobject_cast<QToolButton*>(widget);
    QVERIFY(toolButton);
    QVERIFY(toolButton->isEnabled());
    QVERIFY(toolButton->autoRaise());
    QCOMPARE((int)toolButton->focusPolicy(), (int)Qt::NoFocus);
    QCOMPARE(toolButton->defaultAction(), (QAction*)&selectAction);
    QCOMPARE(toolButton->actions().count(), 4);
    QCOMPARE(toolButton->actions().at(0)->text(), QString("selectAction"));
    QCOMPARE(toolButton->actions().at(1)->text(), QString("action1"));
    QCOMPARE(toolButton->actions().at(2)->text(), QString("action2"));
    QCOMPARE(toolButton->actions().at(3)->text(), QString("action3"));
}
开发者ID:fluxer,项目名称:kdelibs,代码行数:26,代码来源:kselectaction_unittest.cpp

示例2: createActionWidget

QWidget* QgsAttributeTableView::createActionWidget( QgsFeatureId fid )
{
  QgsAttributeTableConfig attributeTableConfig = mFilterModel->layer()->attributeTableConfig();
  QgsActionManager* actions = mFilterModel->layer()->actions();

  QToolButton* toolButton = nullptr;
  QWidget* container = nullptr;

  if ( attributeTableConfig.actionWidgetStyle() == QgsAttributeTableConfig::DropDown )
  {
    toolButton  = new QToolButton( this );
    toolButton->setPopupMode( QToolButton::MenuButtonPopup );
    container = toolButton;
  }
  else
  {
    container = new QWidget( this );
    container->setLayout( new QHBoxLayout() );
    container->layout()->setMargin( 0 );
  }

  for ( int i = 0; i < actions->size(); ++i )
  {
    const QgsAction& action = actions->at( i );

    if ( !action.showInAttributeTable() )
      continue;

    QAction* act = new QAction( action.icon(), action.shortTitle().isEmpty() ? action.name() : action.shortTitle(), toolButton );
    act->setToolTip( action.name() );
    act->setData( i );
    act->setProperty( "fid", fid );

    connect( act, SIGNAL( triggered( bool ) ), this, SLOT( actionTriggered() ) );

    if ( attributeTableConfig.actionWidgetStyle() == QgsAttributeTableConfig::DropDown )
    {
      toolButton->addAction( act );

      if ( actions->defaultAction() == i )
        toolButton->setDefaultAction( act );

      container = toolButton;
    }
    else
    {
      QToolButton* btn = new QToolButton;
      btn->setDefaultAction( act );
      container->layout()->addWidget( btn );
    }
  }

  if ( toolButton && !toolButton->actions().isEmpty() && actions->defaultAction() == -1 )
    toolButton->setDefaultAction( toolButton->actions().first() );

  return container;
}
开发者ID:PeterTFS,项目名称:QGIS,代码行数:57,代码来源:qgsattributetableview.cpp

示例3: eventFilter

bool FullScreenBar::eventFilter(QObject* object, QEvent* event)
{
    if (event->type() == QEvent::MouseMove) {
        QApplication::restoreOverrideCursor();
        d->mAutoHideCursorTimer->start();
        if (y() == 0) {
            if (d->shouldHide()) {
                slideOut();
            }
        } else {
            QMouseEvent* mouseEvent = static_cast<QMouseEvent *>(event);
            if (mouseEvent->buttons() == 0 && d->slideInTriggerRect().contains(QCursor::pos())) {
                slideIn();
            }
        }
        return false;
    }

    if (event->type() == QEvent::MouseButtonRelease) {
        // This can happen if user released the mouse after using a scrollbar
        // in the content (the bar does not hide while a button is down)
        if (y() == 0 && d->shouldHide()) {
            slideOut();
        }
        return false;
    }

    // Filtering message on tooltip text for CJK to remove accelerators.
    // Quoting ktoolbar.cpp:
    // """
    // CJK languages use more verbose accelerator marker: they add a Latin
    // letter in parenthesis, and put accelerator on that. Hence, the default
    // removal of ampersand only may not be enough there, instead the whole
    // parenthesis construct should be removed. Use KLocale's method to do this.
    // """
    if (event->type() == QEvent::Show || event->type() == QEvent::Paint) {
        QToolButton* button = qobject_cast<QToolButton*>(object);
        if (button && !button->actions().isEmpty()) {
            QAction* action = button->actions().first();
            QString toolTip = KGlobal::locale()->removeAcceleratorMarker(action->toolTip());
            // Filtering message requested by translators (scripting).
            button->setToolTip(i18nc("@info:tooltip of custom toolbar button", "%1", toolTip));
        }
    }

    return false;
}
开发者ID:fluxer,项目名称:kde-extraapps,代码行数:47,代码来源:fullscreenbar.cpp


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