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


C++ QAction::setShortcut方法代码示例

本文整理汇总了C++中QAction::setShortcut方法的典型用法代码示例。如果您正苦于以下问题:C++ QAction::setShortcut方法的具体用法?C++ QAction::setShortcut怎么用?C++ QAction::setShortcut使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QAction的用法示例。


在下文中一共展示了QAction::setShortcut方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: QDialog

NewFileDialog::NewFileDialog(QDir *rootDirectory, QWidget *parent, QString caption, QString filename, bool dir) :
    QDialog(parent),
    ui(new Ui::NewFileDialog)
{
    ui->setupUi(this);
    this->setWindowTitle(caption);
    this->dtl = new DirectoryTreeLister(ui->treeWidget, DirectoryTreeLister::NewFile);
    dtl->buildList(rootDirectory);
    connect(dtl, SIGNAL(itemClicked(NPFile*)), this, SLOT(itemClicked(NPFile*)));
    connect(ui->buttonDate, SIGNAL(clicked(bool)), this, SLOT(insertDate()));
    item = 0x0;
    this->rootDir = rootDirectory;
    this->ui->fileLine->setFocus();
    this->ui->fileLine->setText(filename);
    this->ui->fileLine->selectAll();
    if (dir) ui->checkBox->setChecked(true);

    QAction *dateMe = new QAction(this);
    dateMe->setShortcut(QKeySequence("Ctrl+D"));
    connect(dateMe, SIGNAL(triggered(bool)), this, SLOT(insertDate()));
    this->addAction(dateMe);
}
开发者ID:OuluPulu,项目名称:notepuppy,代码行数:22,代码来源:newfiledialog.cpp

示例2: qDebug

void
ComboBox::insertItem(int index,
                     const QString & item,
                     QIcon icon,
                     QKeySequence key,
                     const QString & toolTip)
{
    if (_cascading) {
        qDebug() << "Combobox::insertItem is unsupported when in cascading mode.";

        return;
    }

    assert(index >= 0);
    QAction* action =  new QAction(this);
    action->setText(item);
    action->setData( QVariant(index) );
    if ( !toolTip.isEmpty() ) {
        action->setToolTip( GuiUtils::convertFromPlainText(toolTip.trimmed(), Qt::WhiteSpaceNormal) );
    }
    if ( !icon.isNull() ) {
        action->setIcon(icon);
    }
    if ( !key.isEmpty() ) {
        action->setShortcut(key);
    }

    growMaximumWidthFromText(item);
    boost::shared_ptr<ComboBoxMenuNode> node( new ComboBoxMenuNode() );
    node->text = item;
    node->isLeaf = action;
    node->parent = _rootNode.get();
    _rootNode->isMenu->addAction(node->isLeaf);
    _rootNode->children.insert(_rootNode->children.begin() + index, node);
    /*if this is the first action we add, make it current*/
    if (_rootNode->children.size() == 1) {
        setCurrentText_no_emit( itemText(0) );
    }
}
开发者ID:Kthulhu,项目名称:Natron,代码行数:39,代码来源:ComboBox.cpp

示例3: QDialog

    CodeEditorDialog::CodeEditorDialog(QAbstractItemModel *completionModel, QMenu *variablesMenu, QMenu *resourcesMenu, QWidget *parent)
		: QDialog(parent),
        ui(new Ui::CodeEditorDialog),
        mVariablesMenu(variablesMenu),
        mResourcesMenu(resourcesMenu)
	{
		ui->setupUi(this);
		
		ui->editor->setCompletionModel(completionModel);

		QSettings settings;

		QAction *swapCodeAction = new QAction(this);
		swapCodeAction->setShortcut(QKeySequence(settings.value("actions/switchTextCode", QKeySequence("Ctrl+Shift+C")).toString()));
		swapCodeAction->setShortcutContext(Qt::WindowShortcut);
		addAction(swapCodeAction);

		connect(swapCodeAction, SIGNAL(triggered()), this, SLOT(swapCode()));
		connect(ui->editor, SIGNAL(acceptDialog()), this, SLOT(accept()));
        if(mResourcesMenu)//TMP
            connect(mResourcesMenu, SIGNAL(triggered(QAction*)), this, SLOT(insertVariable(QAction*)));
	}
开发者ID:WeDo30,项目名称:actiona,代码行数:22,代码来源:codeeditordialog.cpp

示例4: createMenus

void AleatoriedadWidget::createMenus(){

    aleatoriedadMenuBar = new QMenuBar;
    menu_Archivo = new QMenu(tr("&Archivo"),aleatoriedadMenuBar);
    menu_Archivo->addAction(guardarAction);
    menu_Archivo->addAction(exportarAction);
    menu_Archivo->addSeparator();
    QAction *tmp = menu_Archivo->addAction(QIcon::fromTheme("application-exit"),
                                   tr("&Salir"), this, SLOT(close()));
    tmp->setMenuRole(QAction::QuitRole);
    tmp->setShortcut(QKeySequence(tr("CTRL+Q")));
    menu_Archivo->addAction(tmp);

    menu_Ayuda = new QMenu(tr("&Ayuda"));
    menu_Ayuda->addAction(action_Sobre);
    menu_Ayuda->addAction(action_Sobre_Qt);

    aleatoriedadMenuBar->addAction(menu_Archivo->menuAction());
    aleatoriedadMenuBar->addAction(menu_Ayuda->menuAction());


}
开发者ID:aleplusplus,项目名称:SESimula,代码行数:22,代码来源:aleatoriedadwidget.cpp

示例5: updateActions

void CommandManager::updateActions()
{
    qDeleteAll(mActions);
    mActions.clear();

    const QList<Command> &commands = mModel->allCommands();

    for (int i = 0; i < commands.size(); ++i) {
        const Command &command = commands.at(i);

        if (!command.isEnabled)
            continue;

        QAction *mAction = new QAction(command.name, this);
        mAction->setShortcut(command.shortcut);

        connect(mAction, &QAction::triggered, [this,i]() { mModel->execute(i); });

        mActions.append(mAction);
    }

    // Add Edit Commands action
    QAction *mSeparator = new QAction(this);
    mSeparator->setSeparator(true);

    mActions.append(mSeparator);

    QAction *mEditCommands = new QAction(this);
    mEditCommands->setIcon(
            QIcon(QLatin1String(":/images/24x24/system-run.png")));
    mEditCommands->setText(tr("Edit Commands..."));
    Utils::setThemeIcon(mEditCommands, "system-run");

    connect(mEditCommands, &QAction::triggered, this, &CommandManager::showDialog);

    mActions.append(mEditCommands);

    populateMenus();
}
开发者ID:Bertram25,项目名称:tiled,代码行数:39,代码来源:commandmanager.cpp

示例6: pageLoadStarted

void QtWebKitWebWidget::pageLoadStarted()
{
	m_isLoading = true;

	m_thumbnail = QPixmap();

	if (m_actions.contains(RewindBackAction))
	{
		getAction(RewindBackAction)->setEnabled(getAction(GoBackAction)->isEnabled());
	}

	if (m_actions.contains(RewindForwardAction))
	{
		getAction(RewindForwardAction)->setEnabled(getAction(GoForwardAction)->isEnabled());
	}

	if (m_actions.contains(ReloadOrStopAction))
	{
		QAction *action = getAction(ReloadOrStopAction);

		ActionsManager::setupLocalAction(action, QLatin1String("Stop"));

		action->setShortcut(QKeySequence());
		action->setEnabled(true);
	}

	if (!isPrivate())
	{
		SessionsManager::markSessionModified();

		m_historyEntry = HistoryManager::addEntry(getUrl(), m_webView->title(), m_webView->icon(), m_isTyped);

		m_isTyped = false;
	}

	emit loadingChanged(true);
	emit statusMessageChanged(QString());
}
开发者ID:Kermit,项目名称:otter,代码行数:38,代码来源:QtWebKitWebWidget.cpp

示例7: QWidget

IncludesWidget::IncludesWidget( QWidget* parent )
    : QWidget ( parent ), ui( new Ui::IncludesWidget )
    , includesModel( new IncludesModel( this ) )
{
    ui->setupUi( this );

    // Hack to workaround broken setIcon(QIcon) overload in QPushButton, the function does not set the icon at all
    // So need to explicitly use the QIcon overload
    ui->addIncludePath->setIcon(QIcon::fromTheme("list-add"));
    ui->removeIncludePath->setIcon(QIcon::fromTheme("list-remove"));

    // hack taken from kurlrequester, make the buttons a bit less in height so they better match the url-requester
    ui->addIncludePath->setFixedHeight( ui->includePathRequester->sizeHint().height() );
    ui->removeIncludePath->setFixedHeight( ui->includePathRequester->sizeHint().height() );

    ui->errorWidget->setHidden(true);
    ui->errorWidget->setMessageType(KMessageWidget::Warning);

    connect( ui->addIncludePath, &QPushButton::clicked, this, &IncludesWidget::addIncludePath );
    connect( ui->removeIncludePath, &QPushButton::clicked, this, &IncludesWidget::deleteIncludePath );

    // also let user choose a file as include path. This file will be "automatically included" in all files. See also -include command line option of clang/gcc
    ui->includePathRequester->setMode( KFile::File | KFile::Directory | KFile::LocalOnly | KFile::ExistingOnly );

    ui->includePaths->setModel( includesModel );
    connect( ui->includePaths->selectionModel(), &QItemSelectionModel::currentChanged, this, &IncludesWidget::includePathSelected );
    connect( ui->includePathRequester, &KUrlRequester::textChanged, this, &IncludesWidget::includePathEdited );
    connect( ui->includePathRequester, &KUrlRequester::urlSelected, this, &IncludesWidget::includePathUrlSelected );
    connect( includesModel, &IncludesModel::dataChanged, this, static_cast<void(IncludesWidget::*)()>(&IncludesWidget::includesChanged) );
    connect( includesModel, &IncludesModel::rowsInserted, this, static_cast<void(IncludesWidget::*)()>(&IncludesWidget::includesChanged)  );
    connect( includesModel, &IncludesModel::rowsRemoved, this, static_cast<void(IncludesWidget::*)()>(&IncludesWidget::includesChanged)  );

    QAction* delIncAction = new QAction( i18n("Delete Include Path"), this );
    delIncAction->setShortcut( QKeySequence( Qt::Key_Delete ) );
    delIncAction->setShortcutContext( Qt::WidgetWithChildrenShortcut );
    ui->includePaths->addAction( delIncAction );
    connect( delIncAction, &QAction::triggered, this, &IncludesWidget::deleteIncludePath );
}
开发者ID:alstef,项目名称:kdevelop,代码行数:38,代码来源:includeswidget.cpp

示例8: createContextMenu

void LiveSelectionTool::createContextMenu(QList<QGraphicsItem*> itemList, QPoint globalPos)
{
    if (!QDeclarativeViewObserverPrivate::get(observer())->mouseInsideContextItem())
        return;

    QMenu contextMenu;
    connect(&contextMenu, SIGNAL(hovered(QAction*)),
            this, SLOT(contextMenuElementHovered(QAction*)));

    m_contextMenuItemList = itemList;

    contextMenu.addAction("Items");
    contextMenu.addSeparator();
    int shortcutKey = Qt::Key_1;
    bool addKeySequence = true;
    int i = 0;

    foreach (QGraphicsItem * const item, itemList) {
        QString itemTitle = titleForItem(item);
        QAction *elementAction = contextMenu.addAction(itemTitle, this,
                                                       SLOT(contextMenuElementSelected()));

        if (observer()->selectedItems().contains(item)) {
            QFont boldFont = elementAction->font();
            boldFont.setBold(true);
            elementAction->setFont(boldFont);
        }

        elementAction->setData(i);
        if (addKeySequence)
            elementAction->setShortcut(QKeySequence(shortcutKey));

        shortcutKey++;
        if (shortcutKey > Qt::Key_9)
            addKeySequence = false;

        ++i;
    }
开发者ID:NoobSaibot,项目名称:qtcreator-minimap,代码行数:38,代码来源:liveselectiontool.cpp

示例9: QDialog

TocDlg::TocDlg(QWidget *parent, CR3View * docView) :
    QDialog(parent),
    m_ui(new Ui::TocDlg), m_docview(docView)
{
    setAttribute(Qt::WA_DeleteOnClose, true);
    m_ui->setupUi(this);
    addAction(m_ui->actionNextPage);
    addAction(m_ui->actionPrevPage);
    addAction(m_ui->actionUpdatePage);

    QAction *actionSelect = m_ui->actionGotoPage;
    actionSelect->setShortcut(Qt::Key_Select);
    addAction(actionSelect);

    m_ui->treeWidget->setColumnCount(2);
    m_ui->treeWidget->header()->setResizeMode(0, QHeaderView::Stretch);
    m_ui->treeWidget->header()->setResizeMode(1, QHeaderView::ResizeToContents);

    int nearestPage = -1;
    int currPage = docView->getCurPage();
    TocItem * nearestItem = NULL;
    LVTocItem * root = m_docview->getToc();
    for (int i=0; i<root->getChildCount(); i++ )
        m_ui->treeWidget->addTopLevelItem(new TocItem(root->getChild(i), currPage, nearestPage, nearestItem));

    m_ui->treeWidget->expandAll();
    if(nearestItem)
        m_ui->treeWidget->setCurrentItem(nearestItem);

    m_ui->pageNumEdit->setValidator(new QIntValidator(1, 999999999, this));
    m_ui->pageNumEdit->installEventFilter(this);
    m_ui->treeWidget->installEventFilter(this);

    // code added 28.11.2011
    countItems = 0;
    countItemsTotal = getMaxItemPosFromBegin(m_docview->getToc(),m_ui->treeWidget->currentItem(),0);
    isPageUpdated = false;
}
开发者ID:CrazyCoder,项目名称:coolreader-kindle-qt,代码行数:38,代码来源:tocdlg.cpp

示例10: initWindow

void MainWindow::initWindow (){
  //set background
  QPixmap pixmap(":/background/res/background/wood0.jpg");
  QPalette   palette;
  palette.setBrush(QPalette::Background,QBrush(pixmap));
  this->setPalette(palette);
  this->setMask(pixmap.mask());  //可以将图片中透明部分显示为透明的
  this->setAutoFillBackground(true); //在调用paintevent之前是否绘制背景图

  //menu
  QAction *newAction = new QAction(trUtf8 ("&New"),this);
  newAction->setIcon (QIcon(":/icon/res/emotes/face-smile.png"));
  newAction->setShortcut (QKeySequence::New);
  newAction->setToolTip ("Start New Game");

  toolbar = new QToolBar(this);
  toolbar->addAction(newAction);
  toolbar->setContextMenuPolicy (Qt::PreventContextMenu);//forbid toolbar's right click which can hide itself
  addToolBar (toolbar);
  this->setCentralWidget (chessboard);
  this->resize (chessboard->size ().width (),chessboard->size ().height ()+50);

}
开发者ID:zhanglongqi,项目名称:wolfAndSheep,代码行数:23,代码来源:mainwindow.cpp

示例11: setupContextMenu

void CallStackView::setupContextMenu()
{
    mMenuBuilder = new MenuBuilder(this, [](QMenu*)
    {
        return DbgIsDebugging();
    });
    QIcon icon = DIcon(ArchValue("processor32.png", "processor64.png"));
    mMenuBuilder->addAction(makeAction(icon, tr("Follow &Address"), SLOT(followAddress())));
    QAction* mFollowTo = mMenuBuilder->addAction(makeAction(icon, tr("Follow &To"), SLOT(followTo())));
    mFollowTo->setShortcutContext(Qt::WidgetShortcut);
    mFollowTo->setShortcut(QKeySequence("enter"));
    connect(this, SIGNAL(enterPressedSignal()), this, SLOT(followTo()));
    mMenuBuilder->addAction(makeAction(icon, tr("Follow &From"), SLOT(followFrom())), [this](QMenu*)
    {
        return !getCellContent(getInitialSelection(), 2).isEmpty();
    });
    MenuBuilder* mCopyMenu = new MenuBuilder(this);
    setupCopyMenu(mCopyMenu);
    // Column count cannot be zero
    mMenuBuilder->addSeparator();
    mMenuBuilder->addMenu(makeMenu(DIcon("copy.png"), tr("&Copy")), mCopyMenu);
    mMenuBuilder->loadFromConfig();
}
开发者ID:bloodwrath,项目名称:x64dbg,代码行数:23,代码来源:CallStackView.cpp

示例12: settings

FileOps::FileOps(QObject *parent) : QObject(parent)
{
    //separators
    QAction *separator1 = new QAction(this);
    separator1->setSeparator (true);
    QAction *separator2 = new QAction(this);
    separator2->setSeparator (true);
    //load settings
    QSignalMapper *mapper = new QSignalMapper(this);
    QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
    settings.beginGroup("FileOps");
    int count = settings.value("count", 0).toInt();
    if (count > 0)
        UiHelper::instance()->addAction(separator1, UiHelper::PLAYLIST_MENU);
    else
        return;

    for (int i = 0; i < count; ++i)
    {

        if (settings.value(QString("enabled_%1").arg(i), true).toBool())
        {
            m_types << settings.value(QString("action_%1").arg(i), FileOps::COPY).toInt();
            QString name = settings.value(QString("name_%1").arg(i), "Action").toString();
            m_patterns << settings.value(QString("pattern_%1").arg(i)).toString();
            m_destinations << settings.value(QString("destination_%1").arg(i)).toString();
            QAction *action = new QAction(name, this);
            action->setShortcut(settings.value(QString("hotkey_%1").arg(i)).toString());
            connect (action, SIGNAL (triggered (bool)), mapper, SLOT (map()));
            mapper->setMapping(action, i);
            UiHelper::instance()->addAction(action, UiHelper::PLAYLIST_MENU);
        }
    }
    settings.endGroup();
    connect(mapper, SIGNAL(mapped(int)), SLOT(execAction(int)));
    UiHelper::instance()->addAction(separator2, UiHelper::PLAYLIST_MENU);
}
开发者ID:Greedysky,项目名称:qmmp,代码行数:37,代码来源:fileops.cpp

示例13: QMainWindow

MainWindow::MainWindow(ModuleLoader &moduleLoader, const ProgramLoader &programLoader, QWidget *parent)
    : QMainWindow(parent),
      moduleLoader(moduleLoader),
      programLoader(programLoader)
{
    createActions();
    createMenus();
    setAcceptDrops(true);

    treeWidget = new TreeWidget(programLoader, this);
    hexFileWidget = new HexFileWidget(this);
    logWidget = new LogWidget();

    setCentralWidget(new QWidget(this));
    QHBoxLayout* layout = new QHBoxLayout(centralWidget());

    QTabWidget* tab = new QTabWidget(centralWidget());
    tab->addTab(hexFileWidget, "hex");
    tab->addTab(logWidget, "log");

    layout->addWidget(treeWidget, 1);
    layout->addWidget(tab);
    layout->setContentsMargins(0,0,0,0);
    centralWidget()->setLayout(layout);

    QAction* search = new QAction(this);
    search->setShortcut(QKeySequence::Find);
    addAction(search);

    connect(treeWidget,SIGNAL(pathChanged(QString)), hexFileWidget, SLOT(setFile(QString)));
    connect(treeWidget,SIGNAL(positionChanged(qint64, qint64)), hexFileWidget, SLOT(gotoPosition(qint64)));
    connect(treeWidget,SIGNAL(positionChanged(qint64, qint64)), hexFileWidget, SLOT(highlight(qint64,qint64)));
    connect(treeWidget,SIGNAL(eventDropped(QDropEvent*)),this, SLOT(dropEvent(QDropEvent*)));
    connect(search, SIGNAL(triggered()), hexFileWidget, SLOT(focusSearch()));
    connect(treeWidget,SIGNAL(openFragmentedFile(Object&)), this, SLOT(openFragmentedFile(Object&)));
    connect(hexFileWidget, SIGNAL(selected(qint64)), treeWidget, SLOT(updateByFilePosition(qint64)));
}
开发者ID:HexaMonkey,项目名称:hexamonkey,代码行数:37,代码来源:mainwindow.cpp

示例14: QDialog

OpenFileDlg::OpenFileDlg(QWidget *parent, CR3View * docView):
    QDialog(parent),
    m_ui(new Ui::OpenFileDlg),
    m_docview(docView)
{
    m_ui->setupUi(this);

    addAction(m_ui->actionGoToBegin);
    addAction(m_ui->actionNextPage);
    addAction(m_ui->actionPrevPage);
    addAction(m_ui->actionGoToFirstPage);
    addAction(m_ui->actionGoToLastPage);

    QAction *actionRemoveFile = m_ui->actionRemoveFile;
    QShortcut* kbd = new QShortcut(Qt::Key_AltGr, this); // quick hack to delete files on K4NT with KBD key
    connect(kbd, SIGNAL(activated()), actionRemoveFile, SLOT(trigger()));
    addAction(actionRemoveFile);

    QAction *actionSelect = m_ui->actionSelectFile;
    actionSelect->setShortcut(Qt::Key_Select);
    addAction(actionSelect);

    folder = QIcon(":/icons/folder_sans_32.png");
    file = QIcon(":/icons/book_text_32.png");
    arrowUp = QIcon(":/icons/arrow_full_up_32.png");

    m_ui->FileList->setItemDelegate(new FileListDelegate());

    QString lastPathName;
    QString lastName;
    if(!docView->GetLastPathName(&lastPathName))
#ifdef i386
        CurrentDir = "/home/";
#else
        CurrentDir = "/mnt/us/documents/";
#endif
    else {
开发者ID:jiedo,项目名称:coolreader-kindle-qt,代码行数:37,代码来源:openfiledlg.cpp

示例15: QDialog

AboutBox::AboutBox(QWidget* parent) : QDialog (parent)
{
    setupUi(this);

    QAction* action = new QAction(this);
    action->setShortcut(QKeySequence(QKeySequence::Close));
    connect(action, SIGNAL(triggered(bool)), this, SLOT(reject()));
    addAction(action);

    m_titleLabel->setText(APPNAME);
    m_versionLabel->setText(APPVERSION);
    m_copyrightLabel->setText(QString("Copyright &copy; <B>Heikki Junnila</B> %1")
                              .arg(tr("and contributors:")));
    m_websiteLabel->setText(tr("Website: %1").arg("<A HREF=\"http://qlc.sourceforge.net\">http://qlc.sourceforge.net</A>"));

    connect(m_contributors, SIGNAL(itemClicked(QListWidgetItem*)),
            this, SLOT(slotItemClicked()));
    m_contributors->clear();
    m_contributors->addItem("janek3");
    m_contributors->addItem("Klaus Weidenbach");
    m_contributors->addItem("Stefan Krumm");
    m_contributors->addItem(QByteArray::fromPercentEncoding("Christian S%fchs"));
    m_contributors->addItem("Simon Newton");
    m_contributors->addItem("Christopher Staite");
    m_contributors->addItem("Lutz Hillebrand");
    m_contributors->addItem("Matthew Jaggard");
    m_contributors->addItem("Ptit Vachon");
    m_contributors->addItem("NiKoyes");
    m_contributors->addItem("Tolmino");

    m_timer = new QTimer(this);
    connect(m_timer, SIGNAL(timeout()), this, SLOT(slotTimeout()));
    m_row = -1;
    m_increment = 1;
    m_timer->start(500);
}
开发者ID:glocklueng,项目名称:qlc,代码行数:36,代码来源:aboutbox.cpp


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