本文整理汇总了C++中QWidget::actions方法的典型用法代码示例。如果您正苦于以下问题:C++ QWidget::actions方法的具体用法?C++ QWidget::actions怎么用?C++ QWidget::actions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWidget
的用法示例。
在下文中一共展示了QWidget::actions方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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"));
}
示例2: visiblePopups
bool AutoHideWidget::visiblePopups() {
//qDebug() << "AutohideWidget::visiblePopups: internal_widget:" << internal_widget;
if (!internal_widget) return false;
// Check if any of the menus in the internal widget is visible
QObjectList children = internal_widget->children();
foreach(QObject * child, children) {
if (child->isWidgetType()) {
//qDebug() << "AutohideWidget::visiblePopups:" << child << "child name:" << child->objectName();
QWidget *w = static_cast<QWidget *>(child);
QList<QAction *> actions = w->actions();
foreach(QAction * action, actions) {
//qDebug() << "AutohideWidget::visiblePopups: action:" << action;
QList<QWidget *> aw = action->associatedWidgets();
//qDebug() << "AutohideWidget::visiblePopups: aw:" << aw;
QMenu * menu = 0;
foreach(QWidget * widget, aw) {
//qDebug() << "AutohideWidget::visiblePopups: widget:" << widget;
if ((menu = qobject_cast<QMenu *>(widget))) {
//qDebug() << "AutohideWidget::visiblePopups: menu:" << menu << "visible:" << menu->isVisible();
if (menu->isVisible()) return true;
}
}
menu = action->menu();
if (menu) {
//qDebug() << "AutohideWidget::visiblePopups: menu:" << menu << "visible:" << menu->isVisible();
if (menu->isVisible()) return true;
}
}
}
示例3:
QList<QAction*> QWidgetProto::actions() const
{
QWidget *item = qscriptvalue_cast<QWidget*>(thisObject());
if (item)
return item->actions();
return QList<QAction*>();
}
示例4: tabChanged
void BTSettingsMainWindow::tabChanged(int /*index*/)
{
m_menu->clear();
QWidget *w = m_tabs->currentWidget();
if (QScrollArea *scroll = qobject_cast<QScrollArea *>(w))
w = scroll->widget();
m_menu->addActions(w->actions());
}
示例5: textChanged
void HelpQuery::textChanged(const QString& ss)
{
QString s = ss.toLower();
QWidget* menu = static_cast<QWidget*>(parent());
if (s.isEmpty()) {
if (!emptyState) { // restore old menu entries
QList<QAction*> al = menu->actions();
for (QAction* a : al) {
if (a != this)
menu->removeAction(a);
}
for (QAction* a : actions) {
if (a != this)
menu->addAction(a);
}
}
emptyState = true;
return;
}
if (emptyState)
actions = menu->actions();
for (QAction* a : menu->actions()) {
if (a != this)
menu->removeAction(a);
}
emptyState = false;
if (!mscore->helpEngine())
return;
QMap<QString,QUrl>list = mscore->helpEngine()->linksForIdentifier(s);
// QMap<QString,QUrl>list = mscore->helpEngine()->indexModel()->linksForKeyword(s);
int k = 0;
for (auto i = list.begin(); i != list.end(); ++i) {
QAction* action = new QAction(i.key(), this);
action->setData(i.value());
// printf("add action <%s> <%s>\n", qPrintable(i.key()), qPrintable(i.value().toString()));
menu->addAction(action);
connect(action, SIGNAL(triggered()), mapper, SLOT(map()));
mapper->setMapping(action, action);
if (++k > 10)
break;
}
}
示例6: appendSoftkeys
bool QSoftKeyManager::appendSoftkeys(const QWidget &source, int level)
{
Q_D(QSoftKeyManager);
bool ret = false;
QList<QAction*> actions = source.actions();
for (int i = 0; i < actions.count(); ++i) {
if (actions.at(i)->softKeyRole() != QAction::NoSoftKey) {
d->requestedSoftKeyActions.insert(level, actions.at(i));
ret = true;
}
}
return ret;
}
示例7: 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"));
}
示例8: showHelpFor
bool HelpViewer::showHelpFor(const QObject* object)
{
if (object == 0) return false;
HashMap<const QObject*, String>::Iterator to_find;
QObject* object2 = (QObject*) object;
QWidget* widget = dynamic_cast<QWidget*>(object2);
if (widget && widget->parent() != 0)
{
QToolBar* tb = dynamic_cast<QToolBar*>(widget->parent());
if (tb != 0)
{
QList<QAction *> acs = widget->actions();
if (acs.size() == 1)
{
to_find = docu_entries_.find(*acs.begin());
if (to_find != docu_entries_.end())
{
showHelp((*to_find).second);
return true;
}
}
}
}
while (object2 != 0)
{
to_find = docu_entries_.find(object2);
if (to_find != docu_entries_.end()) break;
object2 = object2->parent();
}
if (object2 == 0)
{
setStatusbarText(tr("No documentation for this widget available!"), true);
return false;
}
showHelp((*to_find).second);
return true;
}
示例9: eventFilter
//.........这里部分代码省略.........
return false;
}
if (e->type() == QEvent::ShortcutOverride) return false;
if (e->type() == QEvent::KeyRelease) return false;
QMouseEvent* me = dynamic_cast<QMouseEvent*>(e);
QKeyEvent* ke = dynamic_cast<QKeyEvent*>(e);
QShortcutEvent* se = dynamic_cast<QShortcutEvent*>(e);
if (ke != 0 &&
ke->type() == QEvent::KeyPress &&
ke->key() == Qt::Key_Pause)
{
stopTest();
return false;
}
///////////////////////////////////////////////////////
// uniquely identify the active widget:
// walk up the QObject tree and collect all names of QWidgets
///////////////////////////////////////////////////////
// take the sending object
QObject* o = obj;
QObject* parent = 0;
x_ = y_ = 0;
// for mouse events: take widget under the mouse cursor
if (me != 0)
{
widget_ = qApp->widgetAt(me->globalPos());
if (widget_ == 0) return false;
if (widget_->objectName() == "" &&
widget_->actions().size() == 0)
{
widget_ = dynamic_cast<QWidget*>(widget_->parent());
if (widget_ == 0 || widget_->objectName() == "") return false;
}
o = widget_;
QPoint global = me->globalPos();
// if we can not get local coordinates: abort
QPoint local = widget_->mapFromGlobal(global);
if (local.x() < 0 || local.y() < 0 ||
local.x() >= widget_->width() || local.y() >= widget_->height())
{
return false;
}
// for menus: take the position of the action under the cursor
QMenu* menu = dynamic_cast<QMenu*>(o);
if (menu)
{
QAction* action = menu->actionAt(local);
if (action != 0)
{
o = action;
parent = menu;
QRect rect = menu->actionGeometry(action);
local.rx() -= rect.x();
local.ry() -= rect.y();
if (rect.width() == 0 || rect.height() == 0) return false;
x_ = local.x();
y_ = local.y();
}