本文整理汇总了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"));
}
示例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;
}
示例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;
}