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


C++ QMenu::insertAction方法代码示例

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


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

示例1: showNotepadContextMenu

void Notepad::showNotepadContextMenu(const QPoint &pt)
{
    // Set Notepad popup menu
    QMenu *menu = ui->notepadTextEdit->createStandardContextMenu();
    QTextCursor cur = ui->notepadTextEdit->textCursor();
    QAction* first = menu->actions().at(0);

    if (cur.hasSelection()) {
        // Get selected text
        //this->main->add_debug_output("Selected text: " + cur.selectedText());
        this->addr = cur.selectedText();
    } else {
        // Get word under the cursor
        cur.select( QTextCursor::WordUnderCursor);
        //this->main->add_debug_output("Word: " + cur.selectedText());
        this->addr = cur.selectedText();
    }
    ui->actionDisassmble_bytes->setText( "Disassemble bytes at: " + this->addr);
    ui->actionDisassmble_function->setText( "Disassemble function at: " + this->addr);
    ui->actionHexdump_bytes->setText( "Hexdump bytes at: " + this->addr);
    ui->actionCompact_Hexdump->setText( "Compact Hexdump at: " + this->addr);
    ui->actionHexdump_function->setText( "Hexdump function at: " + this->addr);
    menu->insertAction(first, ui->actionDisassmble_bytes);
    menu->insertAction(first, ui->actionDisassmble_function);
    menu->insertAction(first, ui->actionHexdump_bytes);
    menu->insertAction(first, ui->actionCompact_Hexdump);
    menu->insertAction(first, ui->actionHexdump_function);
    menu->insertSeparator(first);
    ui->notepadTextEdit->setContextMenuPolicy(Qt::DefaultContextMenu);
    menu->exec(ui->notepadTextEdit->mapToGlobal(pt));
    delete menu;
    ui->notepadTextEdit->setContextMenuPolicy(Qt::CustomContextMenu);
}
开发者ID:probonopd,项目名称:iaito,代码行数:33,代码来源:notepad.cpp

示例2: contextMenuEvent

void AddressWidget::contextMenuEvent(QContextMenuEvent *event)
{
	const QString shortcut = QKeySequence(QKeySequence::Paste).toString(QKeySequence::NativeText);
	QMenu *menu = createStandardContextMenu();
	bool found = false;

	if (!shortcut.isEmpty())
	{
		for (int i = 0; i < menu->actions().count(); ++i)
		{
			if (menu->actions().at(i)->text().endsWith(shortcut))
			{
				menu->insertAction(menu->actions().at(i + 1), ActionsManager::getAction(PasteAndGoAction));

				found = true;

				break;
			}
		}
	}

	if (!found)
	{
		menu->insertAction(menu->actions().at(6), ActionsManager::getAction(PasteAndGoAction));
	}

	menu->exec(event->globalPos());
	menu->deleteLater();
}
开发者ID:homsar,项目名称:otter,代码行数:29,代码来源:AddressWidget.cpp

示例3: createMenuItems

void DoNothingPlugin::createMenuItems()
{
    // Fetch the action manager
    Core::ActionManager* am = Core::ICore::instance()->actionManager();

    // Create a command for "About DoNothing"
    Core::Command* cmd = am->registerAction(new QAction(this), "DoNothingPlugin.AboutDoNothingItem", QList<int>() << Core::Constants::C_GLOBAL_ID);
    cmd->action()->setText("About DoNothing");

    // Add the command "Do Nothing" in the beginning of Help menu
    am->actionContainer(Core::Constants::M_HELP)->addAction(cmd);

    // Since menu-items are QActions, we can connect to their triggered(bool) or
    // toggled(bool) signal and respond to trigger/toggled events
    connect(cmd->action(), SIGNAL(triggered(bool)), this, SLOT(about()));

    // Create a command for "About DoNothing 2"
    Core::Command* cmd2 = am->registerAction(new QAction(this), "DoNothingPlugin.AboutDoNothing2Item", QList<int>() << Core::Constants::C_GLOBAL_ID);
    cmd2->action()->setText("About DoNothing 2");

    // Insert the "DoNothing 2" item before "About Plugins..."
    QMenu* helpMenu = am->actionContainer(Core::Constants::M_HELP)->menu();
    QAction* aboutPluginsAction = am->command(Core::Constants::ABOUT_PLUGINS)->action();
    helpMenu->insertAction(aboutPluginsAction, cmd2->action());

    // Connect the action
    connect(cmd2->action(), SIGNAL(triggered(bool)), this, SLOT(about()));
}
开发者ID:Kakadu,项目名称:Triss,代码行数:28,代码来源:DoNothingPlugin.cpp

示例4: QObject

SessionViewlet::SessionViewlet(QMainWindow *mainWindow, QObject *parent):
    QObject(parent)
{
    QMenu *sessionMenu = synthclone::getChild<QMenu>(mainWindow, "sessionMenu");

    loadAction = synthclone::getChild<QAction>(mainWindow, "loadSessionAction");
    connect(loadAction, SIGNAL(triggered()), SIGNAL(loadRequest()));

    quitAction = synthclone::getChild<QAction>(mainWindow, "quitSessionAction");
    connect(quitAction, SIGNAL(triggered()), SIGNAL(quitRequest()));

    saveAction = synthclone::getChild<QAction>(mainWindow, "saveSessionAction");
    connect(saveAction, SIGNAL(triggered()), SIGNAL(saveRequest()));

    saveAsAction = synthclone::getChild<QAction>(mainWindow,
                                                 "saveSessionAsAction");
    connect(saveAsAction, SIGNAL(triggered()), SIGNAL(saveAsRequest()));

    // Hack: Optimally, we'd like to give an object name to the separator we
    // want to retrieve from the QtDesigner file.  Unfortunately, QtDesigner
    // doesn't allow the naming of QAction items that are separators (they all
    // have to be named 'separator').  So, we have to add the separator here.
    customItemsSeparator = new QAction(this);
    customItemsSeparator->setSeparator(true);
    sessionMenu->insertAction(quitAction, customItemsSeparator);

    menuViewlet = new MenuViewlet(sessionMenu, customItemsSeparator, this);
}
开发者ID:Omega9,项目名称:synthclone,代码行数:28,代码来源:sessionviewlet.cpp

示例5: init

void QImageDocumentSelectorDialog::init()
{
    setWindowTitle( tr( "Select Image" ) );
    QVBoxLayout *vb = new QVBoxLayout( this );
    vb->setContentsMargins(0, 0, 0, 0);

    connect( selector, SIGNAL(documentSelected(QContent)), this, SLOT(accept()) );
    connect( selector, SIGNAL(documentsChanged()), this, SLOT(setContextBar()) );

    vb->addWidget( selector );

    // Set thumbnail view
    selector->setViewMode( QImageDocumentSelector::Thumbnail );

    QAction *viewAction = new QAction( QIcon( ":icon/view" ), tr( "View" ), this );
    connect( viewAction, SIGNAL(triggered()), this, SLOT(viewImage()) );
    QMenu *menu = QSoftMenuBar::menuFor( selector );
    menu->actions().count() ? menu->insertAction(menu->actions().at(0), viewAction)
    : menu->addAction(viewAction);
    QSoftMenuBar::addMenuTo( this, menu );

    setContextBar();

    setModal( true );
    QtopiaApplication::setMenuLike( this, true );
}
开发者ID:,项目名称:,代码行数:26,代码来源:

示例6: eventFilter

bool QtKeySequenceEdit::eventFilter(QObject *o, QEvent *e)
{
    if (o == m_lineEdit && e->type() == QEvent::ContextMenu) {
        QContextMenuEvent *c = static_cast<QContextMenuEvent *>(e);
        QMenu *menu = m_lineEdit->createStandardContextMenu();
        const QList<QAction *> actions = menu->actions();
        QListIterator<QAction *> itAction(actions);
        while (itAction.hasNext()) {
            QAction *action = itAction.next();
            action->setShortcut(QKeySequence());
            QString actionString = action->text();
            const int pos = actionString.lastIndexOf(QLatin1Char('\t'));
            if (pos > 0)
                actionString.remove(pos, actionString.length() - pos);
            action->setText(actionString);
        }
        QAction *actionBefore = 0;
        if (actions.count() > 0)
            actionBefore = actions[0];
        QAction *clearAction = new QAction(tr("Clear Shortcut"), menu);
        menu->insertAction(actionBefore, clearAction);
        menu->insertSeparator(actionBefore);
        clearAction->setEnabled(!m_keySequence.isEmpty());
        connect(clearAction, SIGNAL(triggered()), this, SLOT(slotClearShortcut()));
        menu->exec(c->globalPos());
        delete menu;
        e->accept();
        return true;
    }

    return QWidget::eventFilter(o, e);
}
开发者ID:phen89,项目名称:rtqt,代码行数:32,代码来源:qtpropertybrowserutils.cpp

示例7: networkUpdated

void ToolBarActionProvider::networkUpdated(const Network *net)
{
    if (!net)
        net = qobject_cast<const Network *>(sender());
    if (!net)
        return;
    Action *act = _networkActions.value(net->networkId());
    if (!act)
        return;

    _networksConnectMenu->removeAction(act);
    _networksDisconnectMenu->removeAction(act);

    QMenu *newMenu = net->connectionState() != Network::Disconnected ? _networksDisconnectMenu : _networksConnectMenu;
    act->setText(net->networkName());

    const int lastidx = newMenu->actions().count() - 2;
    QAction *beforeAction = newMenu->actions().at(lastidx);
    for (int i = 0; i < newMenu->actions().count() - 2; i++) {
        QAction *action = newMenu->actions().at(i);
        if (net->networkName().localeAwareCompare(action->text()) < 0) {
            beforeAction = action;
            break;
        }
    }
    newMenu->insertAction(beforeAction, act);

    action(NetworkConnectAll)->setEnabled(_networksConnectMenu->actions().count() > 2);
    action(NetworkDisconnectAll)->setEnabled(_networksDisconnectMenu->actions().count() > 2);
    action(JoinChannel)->setEnabled(_networksDisconnectMenu->actions().count() > 2);
}
开发者ID:sandsmark,项目名称:quassel-proxy,代码行数:31,代码来源:toolbaractionprovider.cpp

示例8: insertMenuActions

bool ActionManager::insertMenuActions(const QString &idMenu, const QString &idBeforeSep, bool newGroup,  QList<QAction*> &actions)
{
    if (idMenu.isEmpty()) {
        return false;
    }
    QMenu *menu = loadMenu(idMenu);
    if (!menu) {
        return false;
    }
    if (newGroup) {
        QMenu *realMenu = menu->menuAction()->menu();
        if (realMenu) {
            if (!realMenu->actions().isEmpty() && !realMenu->actions().last()->isSeparator()) {
                menu->addSeparator();
            }
        } else {
            menu->addSeparator();
        }
    }
    QAction *sep = 0;
    if (!idBeforeSep.isEmpty()) {
        sep = m_idMenuSepMap[idMenu][idBeforeSep];
        if (!sep) {
            sep = menu->addSeparator();
            m_idMenuSepMap[idMenu].insert(idBeforeSep,sep);
        }
    }
    foreach (QAction *act, actions) {
        menu->insertAction(sep,act);
    }
开发者ID:visualfc,项目名称:liteide,代码行数:30,代码来源:actionmanager.cpp

示例9: InsertMenuItemAction

static void InsertMenuItemAction( const wxMenu *menu, const wxMenuItem *previousItem,
    const wxMenuItem *item, const wxMenuItem *successiveItem )
{
    QMenu *qtMenu = menu->GetHandle();
    QAction *itemAction = item->GetHandle();
    if ( item->GetKind() == wxITEM_RADIO )
    {
        // If the previous menu item is a radio item then add this item to the
        // same action group, otherwise start a new group:

        if ( previousItem != NULL && previousItem->GetKind() == wxITEM_RADIO )
        {
            QAction *previousItemAction = previousItem->GetHandle();
            QActionGroup *previousItemActionGroup = previousItemAction->actionGroup();
            wxASSERT_MSG( previousItemActionGroup != NULL, "An action group should have been setup" );
            previousItemActionGroup->addAction( itemAction );
        }
        else
        {
            QActionGroup *actionGroup = new QActionGroup( qtMenu );
            actionGroup->addAction( itemAction );
            wxASSERT_MSG( itemAction->actionGroup() == actionGroup, "Must be the same action group" );
        }
    }
    // Insert the action into the actual menu:
    QAction *successiveItemAction = ( successiveItem != NULL ) ? successiveItem->GetHandle() : NULL;
    qtMenu->insertAction( successiveItemAction, itemAction );
}
开发者ID:3v1n0,项目名称:wxWidgets,代码行数:28,代码来源:menu.cpp

示例10: createContextMenu

QMenu* CartesianPlotLegend::createContextMenu(){
	QMenu *menu = WorksheetElement::createContextMenu();
	QAction* firstAction = menu->actions().at(1); //skip the first action because of the "title-action"

	visibilityAction->setChecked(isVisible());
	menu->insertAction(firstAction, visibilityAction);

	return menu;
}
开发者ID:asemke,项目名称:labplot,代码行数:9,代码来源:CartesianPlotLegend.cpp

示例11: webViewContextMenu

void MainWindow::webViewContextMenu(const QPoint &pos)
{
    QMenu *contextMenu = new QMenu(this);

    contextMenu->insertAction(0, ui->webView->pageAction(QWebPage::Copy));

    contextMenu->exec(ui->webView->mapToGlobal(pos));
    delete contextMenu;
}
开发者ID:CodingGears,项目名称:CuteMarkEd,代码行数:9,代码来源:mainwindow.cpp

示例12: contextMenuEvent

void LogWindow::contextMenuEvent(QContextMenuEvent *event) {
    QMenu *menu = createStandardContextMenu();
    QAction *a = new QAction("Clear", this);
    a->setEnabled(!document()->isEmpty());
    connect(a, SIGNAL(triggered()), this, SLOT(clear()));
    QList<QAction*> L = menu->actions();
    menu->insertAction(L[0], a);
    menu->exec(event->globalPos());
    delete menu;
}
开发者ID:GinZhu,项目名称:xdog-demo,代码行数:10,代码来源:logwindow.cpp

示例13: contextMenuEvent

void VMdEditor::contextMenuEvent(QContextMenuEvent *p_event)
{
    QMenu *menu = createStandardContextMenu();
    menu->setToolTipsVisible(true);

    VEditTab *editTab = dynamic_cast<VEditTab *>(parent());
    Q_ASSERT(editTab);
    if (editTab->isEditMode()) {
        const QList<QAction *> actions = menu->actions();

        if (textCursor().hasSelection()) {
            initCopyAsMenu(actions.isEmpty() ? NULL : actions.last(), menu);
        } else {
            QAction *saveExitAct = new QAction(VIconUtils::menuIcon(":/resources/icons/save_exit.svg"),
                                               tr("&Save Changes And Read"),
                                               menu);
            saveExitAct->setToolTip(tr("Save changes and exit edit mode"));
            connect(saveExitAct, &QAction::triggered,
                    this, [this]() {
                        emit m_object->saveAndRead();
                    });

            QAction *discardExitAct = new QAction(VIconUtils::menuIcon(":/resources/icons/discard_exit.svg"),
                                                  tr("&Discard Changes And Read"),
                                                  menu);
            discardExitAct->setToolTip(tr("Discard changes and exit edit mode"));
            connect(discardExitAct, &QAction::triggered,
                    this, [this]() {
                        emit m_object->discardAndRead();
                    });

            menu->insertAction(actions.isEmpty() ? NULL : actions[0], discardExitAct);
            menu->insertAction(discardExitAct, saveExitAct);
        }

        if (!actions.isEmpty()) {
            menu->insertSeparator(actions[0]);
        }
    }

    menu->exec(p_event->globalPos());
    delete menu;
}
开发者ID:vscanf,项目名称:vnote,代码行数:43,代码来源:vmdeditor.cpp

示例14: createContextMenu

/*!
    Return a new context menu
*/
QMenu* DatapickerCurve::createContextMenu() {
	QMenu *menu = AbstractAspect::createContextMenu();
	Q_ASSERT(menu);

	QAction* firstAction = 0;
	if (menu->actions().size()>1)
		firstAction = menu->actions().at(1);

	menu->insertAction(firstAction, updateDatasheetAction);

	return menu;
}
开发者ID:gerlachs,项目名称:labplot,代码行数:15,代码来源:DatapickerCurve.cpp

示例15: createContextMenu

QMenu* FileDataSource::createContextMenu(){
	QMenu* menu = AbstractPart::createContextMenu();

	QAction* firstAction = 0;
	// if we're populating the context menu for the project explorer, then
	//there're already actions available there. Skip the first title-action
	//and insert the action at the beginning of the menu.
	if (menu->actions().size()>1)
		firstAction = menu->actions().at(1);

	if (!m_fileWatched)
		menu->insertAction(firstAction, m_reloadAction);

	m_toggleWatchAction->setChecked(m_fileWatched);
	menu->insertAction(firstAction, m_toggleWatchAction);

	m_toggleLinkAction->setChecked(m_fileLinked);
	menu->insertAction(firstAction, m_toggleLinkAction);

	return menu;
}
开发者ID:gerlachs,项目名称:labplot,代码行数:21,代码来源:FileDataSource.cpp


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