本文整理汇总了C++中QWidget::isEnabled方法的典型用法代码示例。如果您正苦于以下问题:C++ QWidget::isEnabled方法的具体用法?C++ QWidget::isEnabled怎么用?C++ QWidget::isEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWidget
的用法示例。
在下文中一共展示了QWidget::isEnabled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
bool
Basic::eventFilter( QObject* object, QEvent *e )
{
QWidget* widget = qobject_cast<QWidget*>(object);
if (!(widget && widget->isVisible()))
return false;
switch (e->type())
{
case QEvent::MouseMove:
case QEvent::Timer:
case QEvent::Move:
case QEvent::Paint:
return false; // just for performance - they can occur really often
case QEvent::Show:
if (widget->isEnabled())
play(widget);
return false;
case QEvent::Hide:
_release(widget);
return false;
case QEvent::EnabledChange:
if (widget->isEnabled())
play(widget);
else
_release(widget);
return false;
default:
return false;
}
}
示例2: testAddEntry
void TestGui::testAddEntry()
{
EntryView* entryView = m_dbWidget->findChild<EntryView*>("entryView");
QAction* entryNewAction = m_mainWindow->findChild<QAction*>("actionEntryNew");
QVERIFY(entryNewAction->isEnabled());
QToolBar* toolBar = m_mainWindow->findChild<QToolBar*>("toolBar");
QWidget* entryNewWidget = toolBar->widgetForAction(entryNewAction);
QVERIFY(entryNewWidget->isVisible());
QVERIFY(entryNewWidget->isEnabled());
QTest::mouseClick(entryNewWidget, Qt::LeftButton);
QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::EditMode);
EditEntryWidget* editEntryWidget = m_dbWidget->findChild<EditEntryWidget*>("editEntryWidget");
QLineEdit* titleEdit = editEntryWidget->findChild<QLineEdit*>("titleEdit");
QTest::keyClicks(titleEdit, "test");
QDialogButtonBox* editEntryWidgetButtonBox = editEntryWidget->findChild<QDialogButtonBox*>("buttonBox");
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::ViewMode);
QModelIndex item = entryView->model()->index(1, 1);
Entry* entry = entryView->entryFromIndex(item);
QCOMPARE(entry->title(), QString("test"));
QCOMPARE(entry->historyItems().size(), 0);
// wait for modified timer
QTRY_COMPARE(m_tabWidget->tabText(m_tabWidget->currentIndex()), QString("%1*").arg(m_orgDbFileName));
QAction* entryEditAction = m_mainWindow->findChild<QAction*>("actionEntryEdit");
QVERIFY(entryEditAction->isEnabled());
QWidget* entryEditWidget = toolBar->widgetForAction(entryEditAction);
QVERIFY(entryEditWidget->isVisible());
QVERIFY(entryEditWidget->isEnabled());
QTest::mouseClick(entryEditWidget, Qt::LeftButton);
QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::EditMode);
QTest::keyClicks(titleEdit, "something");
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
QCOMPARE(entry->title(), QString("testsomething"));
QCOMPARE(entry->historyItems().size(), 1);
QTest::mouseClick(entryNewWidget, Qt::LeftButton);
QTest::keyClicks(titleEdit, "something 2");
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
QTest::mouseClick(entryNewWidget, Qt::LeftButton);
QTest::keyClicks(titleEdit, "something 3");
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
QTRY_COMPARE(entryView->model()->rowCount(), 4);
}
示例3: testSearch
void TestGui::testSearch()
{
QAction* searchAction = m_mainWindow->findChild<QAction*>("actionSearch");
QVERIFY(searchAction->isEnabled());
QToolBar* toolBar = m_mainWindow->findChild<QToolBar*>("toolBar");
QWidget* searchActionWidget = toolBar->widgetForAction(searchAction);
QVERIFY(searchActionWidget->isVisible());
QVERIFY(searchActionWidget->isEnabled());
QTest::mouseClick(searchActionWidget, Qt::LeftButton);
EntryView* entryView = m_dbWidget->findChild<EntryView*>("entryView");
QLineEdit* searchEdit = m_dbWidget->findChild<QLineEdit*>("searchEdit");
QToolButton* clearSearch = m_dbWidget->findChild<QToolButton*>("clearButton");
QTest::keyClicks(searchEdit, "ZZZ");
QTRY_COMPARE(entryView->model()->rowCount(), 0);
QTest::mouseClick(clearSearch, Qt::LeftButton);
QTest::keyClicks(searchEdit, "some");
QTRY_COMPARE(entryView->model()->rowCount(), 2);
QModelIndex item = entryView->model()->index(0, 1);
QRect itemRect = entryView->visualRect(item);
QTest::mouseClick(entryView->viewport(), Qt::LeftButton, Qt::NoModifier, itemRect.center());
QAction* entryEditAction = m_mainWindow->findChild<QAction*>("actionEntryEdit");
QVERIFY(entryEditAction->isEnabled());
QWidget* entryEditWidget = toolBar->widgetForAction(entryEditAction);
QVERIFY(entryEditWidget->isVisible());
QVERIFY(entryEditWidget->isEnabled());
QTest::mouseClick(entryEditWidget, Qt::LeftButton);
QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::EditMode);
EditEntryWidget* editEntryWidget = m_dbWidget->findChild<EditEntryWidget*>("editEntryWidget");
QDialogButtonBox* editEntryWidgetButtonBox = editEntryWidget->findChild<QDialogButtonBox*>("buttonBox");
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::ViewMode);
QModelIndex item2 = entryView->model()->index(1, 0);
QRect itemRect2 = entryView->visualRect(item2);
QTest::mouseClick(entryView->viewport(), Qt::LeftButton, Qt::NoModifier, itemRect2.center());
QAction* entryDeleteAction = m_mainWindow->findChild<QAction*>("actionEntryDelete");
QWidget* entryDeleteWidget = toolBar->widgetForAction(entryDeleteAction);
QVERIFY(entryDeleteWidget->isVisible());
QVERIFY(entryDeleteWidget->isEnabled());
QTest::mouseClick(entryDeleteWidget, Qt::LeftButton);
QWidget* closeSearchButton = m_dbWidget->findChild<QToolButton*>("closeSearchButton");
QTest::mouseClick(closeSearchButton, Qt::LeftButton);
QCOMPARE(entryView->model()->rowCount(), 1);
}
示例4: state
/*! \reimp */
QAccessible::State QAccessibleWidget::state(int child) const
{
if (child)
return Normal;
QAccessible::State state = Normal;
QWidget *w = widget();
if (w->testAttribute(Qt::WA_WState_Visible) == false)
state |= Invisible;
if (w->focusPolicy() != Qt::NoFocus)
state |= Focusable;
if (w->hasFocus())
state |= Focused;
if (!w->isEnabled())
state |= Unavailable;
if (w->isWindow()) {
if (w->windowFlags() & Qt::WindowSystemMenuHint)
state |= Movable;
if (w->minimumSize() != w->maximumSize())
state |= Sizeable;
}
return state;
}
示例5: handleContextMenuEvent
void QWidgetWindow::handleContextMenuEvent(QContextMenuEvent *e)
{
// We are only interested in keyboard originating context menu events here,
// mouse originated context menu events for widgets are generated in mouse handling methods.
if (e->reason() != QContextMenuEvent::Keyboard)
return;
QWidget *fw = QWidget::keyboardGrabber();
if (!fw) {
if (QApplication::activePopupWidget()) {
fw = (QApplication::activePopupWidget()->focusWidget()
? QApplication::activePopupWidget()->focusWidget()
: QApplication::activePopupWidget());
} else if (QApplication::focusWidget()) {
fw = QApplication::focusWidget();
} else {
fw = m_widget;
}
}
if (fw && fw->isEnabled()) {
QPoint pos = fw->inputMethodQuery(Qt::ImMicroFocus).toRect().center();
QContextMenuEvent widgetEvent(QContextMenuEvent::Keyboard, pos, fw->mapToGlobal(pos),
e->modifiers());
QGuiApplication::sendSpontaneousEvent(fw, &widgetEvent);
}
}
示例6: testRequestWidgetMenuModeWidgetParentRemoveActions
void KSelectAction_UnitTest::testRequestWidgetMenuModeWidgetParentRemoveActions()
{
KSelectAction selectAction("selectAction", 0);
selectAction.setToolBarMode(KSelectAction::MenuMode);
QToolBar toolBar;
toolBar.addAction(&selectAction);
QWidget* widget = toolBar.widgetForAction(&selectAction);
QVERIFY(widget);
QAction* action1 = new QAction("action1", &selectAction);
selectAction.addAction(action1);
QAction* action2 = new QAction("action2", &selectAction);
selectAction.addAction(action2);
QAction* action3 = new QAction("action3", &selectAction);
selectAction.addAction(action3);
delete selectAction.removeAction(action1);
delete selectAction.removeAction(action2);
delete selectAction.removeAction(action3);
QVERIFY(!widget->isEnabled());
QCOMPARE(widget->actions().count(), 1);
QCOMPARE(widget->actions().at(0)->text(), QString("selectAction"));
}
示例7: isValidWidget
QWidget* QtEventConsumer::isValidWidget(QObject *obj)
{
// check the object
if (!obj->isWidgetType()){
return NULL;
}
// check the widget
QWidget* w = dynamic_cast<QWidget*>(obj);
_d("W > " << QWidgetUtils::getWidgetPath(w).toStdString());
if (!w) {
DEBUG(D_CONSUMER,"(QtEventConsumer::isValidWidget) Widget is null");
DEBUG(D_CONSUMER,"(QtEventConsumer::isValidWidget) -> " + QWidgetUtils::getWidgetPath(w).toStdString());
return NULL;
}
else if (!w->isVisible()) {
DEBUG(D_CONSUMER,"(QtEventConsumer::isValidWidget) Widget is not visible");
DEBUG(D_CONSUMER,"(QtEventConsumer::isValidWidget) -> " + QWidgetUtils::getWidgetPath(w).toStdString());
return NULL;
}
else if (!w->isEnabled()) {
DEBUG(D_CONSUMER,"(QtEventConsumer::isValidWidget) Widget is not enabled");
DEBUG(D_CONSUMER,"(QtEventConsumer::isValidWidget) -> " + QWidgetUtils::getWidgetPath(w).toStdString());
return NULL;
}
_d("W > " << QWidgetUtils::getWidgetPath(w).toStdString());
_d("VALID WIDGET");
return w;
}
示例8: finalizeJob
//! The Job options are synchronised using the widgetChanged slot, but we still
//! need to determine if the options should be printed as part of the job. This
//! is based on whether or not the associated control is enabled or not.
void InputDialog::finalizeJob(Job* job)
{
if (!job) return;
QWidget* w;
QString name;
StringMap::const_iterator iter;
StringMap s = job->getOptions();
for (iter = s.begin(); iter != s.end(); ++iter) {
name = iter.key();
w = findChild<QWidget*>(name.toLower());
// If there is no widget of this name, then we are probably dealing
// with something the user wrote into the preview box, so we just
// leave things alone.
if (w) job->printOption(name, w->isEnabled());
}
// Special case code to avoid writing the method keyword when custom is
// chosen (for backward compatibility)
QComboBox* method(findChild<QComboBox*>("method"));
QString m(method->currentText());
if (method && (m == "Custom" || m == "TD-DFT")) {
job->printOption("METHOD", false);
job->printOption("EXCHANGE", true);
}
}
示例9: setCurrentIndex
/*!
\property QStackedLayout::currentIndex
\brief the index position of the widget that is visible
The current index is -1 if there is no current widget.
\sa currentWidget(), indexOf()
*/
void QStackedLayout::setCurrentIndex(int index)
{
Q_D(QStackedLayout);
QWidget *prev = currentWidget();
QWidget *next = widget(index);
if (!next || next == prev)
return;
bool reenableUpdates = false;
QWidget *parent = parentWidget();
if (parent && parent->updatesEnabled()) {
reenableUpdates = true;
parent->setUpdatesEnabled(false);
}
QWidget *fw = parent ? parent->window()->focusWidget() : 0;
if (prev) {
prev->clearFocus();
if (d->stackingMode == StackOne)
prev->hide();
}
d->index = index;
next->raise();
next->show();
// try to move focus onto the incoming widget if focus
// was somewhere on the outgoing widget.
if (parent) {
if (fw && (prev && prev->isAncestorOf(fw))) { // focus was on old page
// look for the best focus widget we can find
if (QWidget *nfw = next->focusWidget())
nfw->setFocus();
else {
// second best: first child widget in the focus chain
QWidget *i = fw;
while ((i = i->nextInFocusChain()) != fw) {
if (((i->focusPolicy() & Qt::TabFocus) == Qt::TabFocus)
&& !i->focusProxy() && i->isVisibleTo(next) && i->isEnabled()
&& next->isAncestorOf(i)) {
i->setFocus();
break;
}
}
// third best: incoming widget
if (i == fw )
next->setFocus();
}
}
}
if (reenableUpdates)
parent->setUpdatesEnabled(true);
emit currentChanged(index);
}
示例10: zoomToMin
void GTUtilsAssemblyBrowser::zoomToMin(HI::GUITestOpStatus &os) {
Q_UNUSED(os);
QToolBar* toolbar = GTToolbar::getToolbar(os, MWTOOLBAR_ACTIVEMDI);
GT_CHECK(NULL != toolbar, "Can't find the toolbar");
QWidget* zoomOutButton = GTToolbar::getWidgetForActionTooltip(os, toolbar, "Zoom out");
GT_CHECK(NULL != zoomOutButton, "Can't find the 'Zoom in' button");
while (zoomOutButton->isEnabled()) {
GTWidget::click(os, zoomOutButton);
}
}
示例11: testRequestWidgetMenuModeWidgetParentAddActions
void KSelectAction_UnitTest::testRequestWidgetMenuModeWidgetParentAddActions()
{
KSelectAction selectAction("selectAction", 0);
selectAction.setToolBarMode(KSelectAction::MenuMode);
QToolBar toolBar;
toolBar.addAction(&selectAction);
QWidget* widget = toolBar.widgetForAction(&selectAction);
QVERIFY(widget);
QVERIFY(!widget->isEnabled());
selectAction.addAction(new QAction("action1", &selectAction));
selectAction.addAction(new QAction("action2", &selectAction));
selectAction.addAction(new QAction("action3", &selectAction));
QVERIFY(widget->isEnabled());
QCOMPARE(widget->actions().count(), 4);
QCOMPARE(widget->actions().at(0)->text(), QString("selectAction"));
QCOMPARE(widget->actions().at(1)->text(), QString("action1"));
QCOMPARE(widget->actions().at(2)->text(), QString("action2"));
QCOMPARE(widget->actions().at(3)->text(), QString("action3"));
}
示例12: getStyleOption
QStyleOptionMenuItem KxMenuItemWidget::getStyleOption() const
{
QWidget *q = parentWidget();
QMenu *menu = (QMenu *)q;
KxMenuItem *action = fMenuItem;
QStyleOptionMenuItem opt;
opt.initFrom(this);
opt.palette = q->palette();
opt.state = QStyle::State_None;
if (q->window()->isActiveWindow())
opt.state |= QStyle::State_Active;
if (q->isEnabled() && action->isEnabled()
&& (!action->menu() || action->menu()->isEnabled()))
opt.state |= QStyle::State_Enabled;
else
opt.palette.setCurrentColorGroup(QPalette::Disabled);
opt.font = action->font();
if (menu->activeAction() == action && !action->isSeparator()) {
opt.state |= QStyle::State_Selected;
// | (mouseDown ? QStyle::State_Sunken : QStyle::State_None);
}
if (!action->isCheckable()) {
opt.checkType = QStyleOptionMenuItem::NotCheckable;
} else {
opt.checkType = (action->actionGroup() && action->actionGroup()->isExclusive())
? QStyleOptionMenuItem::Exclusive : QStyleOptionMenuItem::NonExclusive;
opt.checked = action->isChecked();
}
if (action->menu())
opt.menuItemType = QStyleOptionMenuItem::SubMenu;
else if (action->isSeparator())
opt.menuItemType = QStyleOptionMenuItem::Separator;
else if (menu->defaultAction() == action)
opt.menuItemType = QStyleOptionMenuItem::DefaultItem;
else
opt.menuItemType = QStyleOptionMenuItem::Normal;
opt.icon = action->icon();
opt.text = action->text();
opt.menuRect = q->rect();
return opt;
}
示例13: childEvent
/*!\reimp */
void QGroupBox::childEvent(QChildEvent *c)
{
Q_D(QGroupBox);
if (c->type() != QEvent::ChildAdded || !c->child()->isWidgetType())
return;
QWidget *w = (QWidget*)c->child();
if (d->checkable) {
if (d->checked) {
if (!w->testAttribute(Qt::WA_ForceDisabled))
w->setEnabled(true);
} else {
if (w->isEnabled()) {
w->setEnabled(false);
w->setAttribute(Qt::WA_ForceDisabled, false);
}
}
}
}
示例14: filterButton_clicked
void FilterWidget::filterButton_clicked()
{
TQueryMap opts;
Attr *a = 0;
for( int i = 0; i < attrList.size(); i++ )
{
QApplication::processEvents();
a = attrList.at(i);
if ( widgetMap.contains( a->getName() ) )
{
QWidget *w = widgetMap[a->getName() ];
if ( false == w->isEnabled() )
continue;
QString v = getWidgetData( a, w );
if ( !v.isEmpty() ) {
int flag = Like | Case;
bool ok;
v.toInt(&ok, 10);
if ( ok ) {
flag = Equal;
}
if (a->getType() == Attr::Bool) {
flag = Equal;
}
if ( opts.size() > 0 ) {
flag |= And;
}
opts.insert(a->getName(),keeper->prepareParam(flag, v));
}
}
}
emit filterActivated(opts);
}
示例15: _q_setChildrenEnabled
/*
sets all children of the group box except the qt_groupbox_checkbox
to either disabled/enabled
*/
void QGroupBoxPrivate::_q_setChildrenEnabled(bool b)
{
Q_Q(QGroupBox);
QObjectList childList = q->children();
for (int i = 0; i < childList.size(); ++i) {
QObject *o = childList.at(i);
if (o->isWidgetType()) {
QWidget *w = static_cast<QWidget *>(o);
if (b) {
if (!w->testAttribute(Qt::WA_ForceDisabled))
w->setEnabled(true);
} else {
if (w->isEnabled()) {
w->setEnabled(false);
w->setAttribute(Qt::WA_ForceDisabled, false);
}
}
}
}
}