本文整理汇总了C++中QWidget::addAction方法的典型用法代码示例。如果您正苦于以下问题:C++ QWidget::addAction方法的具体用法?C++ QWidget::addAction怎么用?C++ QWidget::addAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWidget
的用法示例。
在下文中一共展示了QWidget::addAction方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createWidgetsContainer
void SkinStyle::createWidgetsContainer(QWidget * widget, const QString & objectName) {
QWidget * container = new QWidget(widget->parentWidget());
container->setObjectName(objectName);
QHBoxLayout * layout = new QHBoxLayout();
container->setLayout(layout);
QObjectList objects = widget->children();
for (int i = 0; i < objects.size(); i++) {
QObject * object = objects.at(i);
if (object->isWidgetType()) {
if (!object->inherits("QToolBarHandle") && !object->inherits("QToolBarExtension")) {
QWidget * w = qobject_cast < QWidget * > (object);
addWidgetToLayout(w, layout);
w->show();
}
}
else if (object->inherits("QAction")) {
QAction * a = qobject_cast < QAction * > (object);
QWidget * w = new QWidget(container);
w->addAction(a);
addWidgetToLayout(w, layout);
}
else if (object->inherits("QLayout")) {
QLayout * l = qobject_cast < QLayout * > (object);
layout->addLayout(l);
}
}
container->show();
}
示例2: addAction
void SoftkeysActionBoxModule::addAction(QAction *action)
{
QWidget *p = this;
while (p->parentWidget() && !p->isWindow()) {
p = p->parentWidget();
}
p->addAction(action);
}
示例3: addActionToParent
void MyAction::addActionToParent() {
if (parent()) {
if (parent()->inherits("QWidget")) {
QWidget *w = static_cast<QWidget*> (parent());
w->addAction(this);
}
}
}
示例4: 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;
}
}
示例5: themer
void
KdmLabel::doPlugActions( bool plug )
{
if (action) {
QWidget *w = themer()->widget();
if (plug)
w->addAction( action );
else
w->removeAction( action );
}
}
示例6: parseArgs
void Application::parseArgs( const QStringList &args )
{
QStringList params = args;
params.removeAll("-capi");
params.removeAll("-cng");
params.removeAll("-pkcs11");
params.removeAll("-noNativeFileDialog");
QWidget *w = new MainWindow();
#ifdef Q_OS_MAC
w->installEventFilter( d->bar );
#endif
w->addAction( d->closeAction );
w->activateWindow();
w->show();
w->raise();
if( !params.isEmpty() )
QMetaObject::invokeMethod( w, "open", Q_ARG(QStringList,params) );
}
示例7: QAction
StelAction::StelAction(const QString& actionId,
const QString& groupId,
const QString& text,
const QString& primaryKey,
const QString& altKey,
bool global):
QObject(StelApp::getInstance().getStelActionManager()),
group(groupId),
text(text),
global(global),
keySequence(primaryKey),
altKeySequence(altKey),
defaultKeySequence(primaryKey),
defaultAltKeySequence(altKey),
target(NULL),
boolProperty(NULL)
#ifndef USE_QUICKVIEW
,qAction(NULL)
#endif
{
setObjectName(actionId);
// Check the global conf for custom shortcuts.
QSettings* conf = StelApp::getInstance().getSettings();
QString confShortcut = conf->value("shortcuts/" + actionId).toString();
if (!confShortcut.isEmpty())
{
QStringList shortcuts = confShortcut.split(" ");
if (shortcuts.size() > 2)
qWarning() << actionId << ": does not support more than two shortcuts per action";
setShortcut(shortcuts[0]);
if (shortcuts.size() > 1)
setAltShortcut(shortcuts[1]);
}
#ifndef USE_QUICKVIEW
QWidget* mainView = &StelMainView::getInstance();
qAction = new QAction(this);
onChanged();
mainView->addAction(qAction);
connect(qAction, SIGNAL(triggered()), this, SLOT(trigger()));
connect(this, SIGNAL(changed()), this, SLOT(onChanged()));
#endif
}
示例8: addAction
void QWidgetProto::addAction(QAction *action)
{
QWidget *item = qscriptvalue_cast<QWidget*>(thisObject());
if (item)
item->addAction(action);
}