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


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

本文整理汇总了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;
		}
	}
开发者ID:leewood,项目名称:kadu,代码行数:32,代码来源:toolbar.cpp

示例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"));
}
开发者ID:fluxer,项目名称:kdelibs,代码行数:26,代码来源:kselectaction_unittest.cpp

示例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());
}
开发者ID:quazgar,项目名称:kdepimlibs,代码行数:10,代码来源:emaileditwidgettest.cpp


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