本文整理汇总了C++中QAction::trigger方法的典型用法代码示例。如果您正苦于以下问题:C++ QAction::trigger方法的具体用法?C++ QAction::trigger怎么用?C++ QAction::trigger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAction
的用法示例。
在下文中一共展示了QAction::trigger方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: triggerNavigationAction
void WebViewAbstraction::triggerNavigationAction(QtWebKit::NavigationAction which)
{
QAction* touchAction = touchWebView()->page()->navigationController()->navigationAction(which);
touchAction->trigger();
QAction* desktopAction = desktopWebView()->navigationController()->navigationAction(which);
desktopAction->trigger();
}
示例2: toggleViewAction
void tst_QToolBar::toggleViewAction()
{
{
QToolBar tb;
QAction *toggleViewAction = tb.toggleViewAction();
QVERIFY(tb.isHidden());
toggleViewAction->trigger();
QVERIFY(!tb.isHidden());
toggleViewAction->trigger();
QVERIFY(tb.isHidden());
}
{
QMainWindow mw;
QToolBar tb(&mw);
mw.addToolBar(&tb);
mw.show();
QAction *toggleViewAction = tb.toggleViewAction();
QVERIFY(!tb.isHidden());
toggleViewAction->trigger();
QVERIFY(tb.isHidden());
toggleViewAction->trigger();
QVERIFY(!tb.isHidden());
toggleViewAction->trigger();
QVERIFY(tb.isHidden());
}
}
示例3: testFolding_py_lang
void KateFoldingTest::testFolding_py_lang()
{
KTemporaryFile file;
file.setSuffix(".py");
file.open();
QTextStream stream(&file);
stream << "if customerName == x\n"
<< " print x\n"
<< "elif customerName == y\n"
<< " print y\n"
<< "else print z\n";
stream << flush;
file.close();
KateDocument doc(false, false, false);
QVERIFY(doc.openUrl(KUrl(file.fileName())));
KateView* view = new KateView(&doc, 0);
// is set to allow kate's hl to be called
view->config()->setDynWordWrap(true);
QCOMPARE(doc.visibleLines(), 6u);
QAction* action = view->action("folding_toplevel");
QVERIFY(action);
action->trigger();
QCOMPARE(doc.visibleLines(), 4u);
action = view->action("folding_expandtoplevel");
QVERIFY(action);
action->trigger();
QCOMPARE(doc.visibleLines(), 6u);
}
示例4: testFolding_collapse_expand_local
void KateFoldingTest::testFolding_collapse_expand_local()
{
KTemporaryFile file;
file.setSuffix(".c");
file.open();
QTextStream stream(&file);
stream << "if () {\n"
<< " if () {\n"
<< " if () {\n"
<< " if () {\n"
<< " }\n"
<< " }\n"
<< " }\n"
<< " if () {\n"
<< " foo()\n"
<< " }\n"
<< " }\n";
stream << flush;
file.close();
KateDocument doc(false, false, false);
QVERIFY(doc.openUrl(KUrl(file.fileName())));
KateView* view = new KateView(&doc, 0);
// is set to allow kate's hl to be called
view->config()->setDynWordWrap(true);
QCOMPARE(doc.visibleLines(), 12u);
view->setCursorPosition(KTextEditor::Cursor(2,12));
QAction* action = view->action("folding_collapselocal");
QVERIFY(action);
action->trigger();
QCOMPARE(doc.visibleLines(), 9u);
view->setCursorPosition(KTextEditor::Cursor(2,11));
action = view->action("folding_collapselocal");
QVERIFY(action);
action->trigger();
QCOMPARE(doc.visibleLines(), 7u);
view->setCursorPosition(KTextEditor::Cursor(1,9));
action = view->action("folding_expandlocal");
QVERIFY(action);
action->trigger();
QCOMPARE(doc.visibleLines(), 9u);
}
示例5: toggleViewAction
void tst_QDockWidget::toggleViewAction()
{
QMainWindow mw;
QDockWidget dw(&mw);
mw.addDockWidget(Qt::LeftDockWidgetArea, &dw);
mw.show();
QAction *toggleViewAction = dw.toggleViewAction();
QVERIFY(!dw.isHidden());
toggleViewAction->trigger();
QVERIFY(dw.isHidden());
toggleViewAction->trigger();
QVERIFY(!dw.isHidden());
toggleViewAction->trigger();
QVERIFY(dw.isHidden());
}
示例6: triggerAction
void TestGui::triggerAction(const QString& name)
{
QAction* action = m_mainWindow->findChild<QAction*>(name);
QVERIFY(action);
QVERIFY(action->isEnabled());
action->trigger();
}
示例7: local
QMenu * MainWindowBase::getLanguageMenu(const QString &qmFileDirPath, const QString &local){
qDebug()<<"--setupLanguageMenu(...) "<<" qmFileDirPath:"<<qmFileDirPath<<" local:"<<local;
qmPath = qmFileDirPath;
qmLocale = local;
if(!m_languageMenu){
m_languageMenu = new QMenu(tr("&Language"), this);
//Language
actionLanguageDefaultEnglish = new QAction(tr("Default(English)"), this);
actionLanguageDefaultEnglish->setData("en_US");
actionLanguageDefaultEnglish->setCheckable(true);
m_languageMenu->addAction(actionLanguageDefaultEnglish);
QActionGroup *languageActionGroup = new QActionGroup(this);
languageActionGroup->addAction(actionLanguageDefaultEnglish);
QObject::connect(languageActionGroup, SIGNAL(triggered(QAction *)), this,
SLOT(slotChangeLanguage(QAction*)));
QStringList translationLanguages = Utilities::availableTranslationLanguages(qmPath);
//如果没有找到语言文件或者首选语言是英语,则将"en_US"置为选中
//If no language file is found or the preferred language is English, set the "en_US" menu checked
if (translationLanguages.isEmpty()) {
actionLanguageDefaultEnglish->setChecked(true);
m_preferedLanguage = "en_US";
return m_languageMenu;
}
if (!translationLanguages.contains(qmLocale)){
qmLocale = "en_US";
}
if(qmLocale == "en_US"){
actionLanguageDefaultEnglish->setChecked(true);
}
//为每一个语言文件生成动作为菜单
//Make action and menu for each language file
for (int i = 0; i < translationLanguages.size(); i++){
QString translationLanguage = translationLanguages[i];
QLocale local(translationLanguage);
QString LanguageName = QLocale::languageToString(local.language());
QString regionName = QLocale::countryToString(local.country());
//QAction *action = new QAction(tr("&%1 %2") .arg(i + 1).arg(translationLanguage), this);
QAction *action = new QAction(tr("%1(%2)") .arg(LanguageName).arg(regionName), this);
action->setCheckable(true);
action->setData(translationLanguage);
m_languageMenu->addAction(action);
languageActionGroup->addAction(action);
if (qmLocale == translationLanguage) {
action->setChecked(true);
action->trigger();
}
}
}
示例8: mouseDoubleClickEvent
void MacroLinkItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
{
QAction* macroWatch = Resource::action(Resource::MACRO_WATCHOUTPUT);
macroWatch->setData(reinterpret_cast<qulonglong>(edge().srcPin().data()));
macroWatch->trigger();
event->accept();
}
示例9: insertTab
int ChoqokTabBar::insertTab( int index , QWidget *widget , const QIcon & input_icon , const QString & name )
{
KIcon icon( input_icon );
if( icon.isNull() )
icon = KIcon( "edit-find" );
QAction *action = new QAction( icon , name , this );
action->setCheckable( true );
p->actions_list.insert( index , action );
p->st_widget->insertWidget( index , widget );
connect( widget , SIGNAL(destroyed(QObject*)) , SLOT(widget_destroyed(QObject*)) );
for( int i=0 ; i<p->history_list.count() ; i++ )
if( p->history_list.at(i) >= index )
p->history_list[ i ]++;
refreshTabBar();
if( count() == 1 )
{
action->trigger();
p->history_list << 0;
}
return index;
}
示例10: testFolding_collapse_dsComments_XML
void KateFoldingTest::testFolding_collapse_dsComments_XML()
{
KTemporaryFile file;
file.setSuffix(".xml");
file.open();
QTextStream stream(&file);
stream << "<test1>\n"
<< "</test1>\n"
<< "<!--\n"
<< "<test2>\n"
<< "</test2>\n"
<< "-->\n"
<< "<!--\n"
<< "-->\n";
stream << flush;
file.close();
KateDocument doc(false, false, false);
QVERIFY(doc.openUrl(KUrl(file.fileName())));
KateView* view = new KateView(&doc, 0);
// is set to allow kate's hl to be called
view->config()->setDynWordWrap(true);
QCOMPARE(doc.visibleLines(), 9u);
QAction* action = view->action("folding_collapse_dsComment");
QVERIFY(action);
action->trigger();
QCOMPARE(doc.visibleLines(), 5u);
}
示例11: oscAction
void MuseScore::oscAction()
{
PathObject* pathObject = qobject_cast<PathObject*>(sender());
QString path = pathObject->path().mid(9);
QAction* a = getAction(path.toLocal8Bit().data());
a->trigger();
}
示例12: testKateDocumentAndViewCreation
void TestShellDocumentOperation::testKateDocumentAndViewCreation()
{
//create one document
IDocumentController *documentController = Core::self()->documentController();
documentController->openDocumentFromText(QLatin1String(""));
QCOMPARE(documentController->openDocuments().count(), 1);
//assure we have only one kate view for the newly created document
KTextEditor::Document *doc = documentController->openDocuments().at(0)->textDocument();
QCOMPARE(doc->views().count(), 1);
QCOMPARE(dynamic_cast<KTextEditor::MovingInterface*>(doc)->revision(), qint64(0));
//also assure the view's xmlgui is plugged in
KParts::MainWindow *main = Core::self()->uiControllerInternal()->activeMainWindow();
QVERIFY(main);
QVERIFY(main->guiFactory()->clients().contains(doc->views().at(0)));
//KTextEditor::views is internally a QHash::keys() call: so the order of the views will vary
const auto originalView = doc->views().at(0);
//create the new view and activate it (using split action from mainwindow)
QAction *splitAction = main->actionCollection()->action(QStringLiteral("split_vertical"));
QVERIFY(splitAction);
splitAction->trigger();
const auto viewList = doc->views();
QCOMPARE(viewList.count(), 2);
const auto newlySplitView = originalView == viewList[0] ? viewList[1] : viewList[0];
//check that we did switch to the new xmlguiclient
QVERIFY(!main->guiFactory()->clients().contains(originalView));
QVERIFY(main->guiFactory()->clients().contains(newlySplitView));
documentController->openDocuments().at(0)->close(IDocument::Discard);
}
示例13: eventFilter
bool AccountView::eventFilter(QObject *obj, QEvent *event)
{
if (obj == account_menu_ && event->type() == QEvent::MouseButtonRelease) {
QMouseEvent *ev = (QMouseEvent*)event;
QAction *action = account_menu_->actionAt(ev->pos());
if (action) {
action->trigger();
}
}
if (obj == mAccountBtn && event->type() == QEvent::Paint) {
QRect rect(0, 0, AvatarService::kAvatarSize, AvatarService::kAvatarSize);
QPainter painter(mAccountBtn);
painter.setRenderHint(QPainter::Antialiasing);
painter.setRenderHint(QPainter::HighQualityAntialiasing);
// get the device pixel radio from current painter device
double scale_factor = globalDevicePixelRatio();
QPixmap image(mAccountBtn->icon().pixmap(rect.size()).scaled(scale_factor * rect.size()));
QRect actualRect(QPoint(0, 0),
QSize(AvatarService::kAvatarSize * scale_factor,
AvatarService::kAvatarSize * scale_factor));
QImage masked_image(actualRect.size(),
QImage::Format_ARGB32_Premultiplied);
masked_image.fill(Qt::transparent);
QPainter mask_painter;
mask_painter.begin(&masked_image);
mask_painter.setRenderHint(QPainter::Antialiasing);
mask_painter.setRenderHint(QPainter::HighQualityAntialiasing);
mask_painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
mask_painter.setPen(Qt::NoPen);
mask_painter.setBrush(Qt::white);
mask_painter.drawEllipse(actualRect);
mask_painter.setCompositionMode(QPainter::CompositionMode_SourceIn);
mask_painter.drawPixmap(actualRect, image);
mask_painter.setCompositionMode(QPainter::CompositionMode_DestinationOver);
mask_painter.fillRect(actualRect, Qt::transparent);
mask_painter.end();
masked_image.setDevicePixelRatio(scale_factor);
painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
painter.drawImage(QPoint(0,0), masked_image);
return true;
}
if (obj == mRefreshLabel) {
if (event->type() == QEvent::MouseButtonPress) {
emit refresh();
return true;
} else if (event->type() == QEvent::Enter) {
mRefreshLabel->setPixmap(QIcon(":/images/toolbar/refresh-orange.png").pixmap(20));
return true;
} else if (event->type() == QEvent::Leave) {
mRefreshLabel->setPixmap(QIcon(":/images/toolbar/refresh-new.png").pixmap(20));
return true;
}
}
return QObject::eventFilter(obj, event);
}
示例14: activatedUnReadChat
void SystemTrayIcon::activatedUnReadChat()
{
QAction *act = actions_.back();
if ( act )
{
act->trigger();
}
}
示例15: triggerMainWindowActionWithObjectName
void triggerMainWindowActionWithObjectName(QString actionName)
{
QAction* action = findMainWindowChildWithObjectName<QAction*>(actionName);
if(action)
{
action->trigger();
}
}