本文整理汇总了C++中QToolButton::isEnabled方法的典型用法代码示例。如果您正苦于以下问题:C++ QToolButton::isEnabled方法的具体用法?C++ QToolButton::isEnabled怎么用?C++ QToolButton::isEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QToolButton
的用法示例。
在下文中一共展示了QToolButton::isEnabled方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eventFilter
virtual bool eventFilter(QObject *o, QEvent *e)
{
QToolButton *button = qobject_cast<QToolButton *>(o);
if (!button)
return false;
if (button->isEnabled())
return false;
ToolBar *toolbar = qobject_cast<ToolBar *>(button->parentWidget());
if (!toolbar)
return false;
switch (e->type())
{
case QEvent::MouseButtonPress:
toolbar->widgetPressed();
return true;
case QEvent::MouseMove:
{
QMouseEvent event(QEvent::MouseMove, toolbar->mapFromGlobal(QCursor::pos()), Qt::NoButton, ((QMouseEvent *)e)->buttons(), ((QMouseEvent *)e)->modifiers());
toolbar->mouseMoveEvent(&event);
return event.isAccepted();
}
case QEvent::ContextMenu:
{
QContextMenuEvent event(QContextMenuEvent::Mouse, toolbar->mapFromGlobal(QCursor::pos()));
toolbar->contextMenuEvent(&event);
return event.isAccepted();
}
default:
return false;
}
}
示例2: 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"));
}
示例3: shouldReadOnly
void EmailEditWidgetTest::shouldReadOnly()
{
EmailEditWidget widget;
widget.setReadOnly(true);
QLineEdit *lineedit = widget.findChild<QLineEdit *>(QStringLiteral("emailedit"));
QToolButton *toolButton = widget.findChild<QToolButton *>(QStringLiteral("editbutton"));
QVERIFY(lineedit->isReadOnly());
QVERIFY(!toolButton->isEnabled());
}