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


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

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


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

示例1: slotContextMenu

void QueuedUsers::slotContextMenu(){
    QModelIndexList indexes = treeView_USERS->selectionModel()->selectedRows(0);

    if (indexes.isEmpty())
        return;

    QMenu *m = new QMenu(this);
    m->addAction(tr("Grant slot"));

    if (m->exec(QCursor::pos())){
        for (const auto &i : indexes){
            QueuedUserItem *item = reinterpret_cast<QueuedUserItem*>(i.internalPointer());

            if (!item)
                continue;

            QString id = item->cid;

            if (!id.isEmpty()){
                UserPtr user = ClientManager::getInstance()->findUser(CID(id.toStdString()));

                if (user){
                    try { UploadManager::getInstance()->reserveSlot(HintedUser(user, _tq(item->hub))); }
                    catch ( ... ) {}
                }
            }

        }
    }

    m->deleteLater();
}
开发者ID:eiskaltdcpp,项目名称:eiskaltdcpp,代码行数:32,代码来源:QueuedUsers.cpp

示例2: GetPopUpMenu

void CGI_SCADA_DLL_TreeItemNET::GetPopUpMenu()
{
    QMenu *SwitchMenu = new QMenu();

    QAction *pAddLink = new QAction(tr("新建连接"), SwitchMenu);
    connect(pAddLink, SIGNAL(triggered()), this, SLOT(slot_AddLink()));

    QAction *pDeleteChannel = new QAction(tr("删除通道"), SwitchMenu);
    connect(pDeleteChannel, SIGNAL(triggered()), this, SLOT(slot_DeleteChannel()));

    QAction *pSetEnable = new QAction(tr("使能通道"), SwitchMenu);
    pSetEnable->setCheckable(true);
    if (this->isDisabled())
    {
        pSetEnable->setChecked(false);
    }else
    {
        pSetEnable->setChecked(true);
    }
//    this->isDisabled();
    connect(pSetEnable, SIGNAL(triggered(bool)), this, SLOT(slot_SetEnable(bool)));

    SwitchMenu->addAction(pAddLink);
    SwitchMenu->addAction(pDeleteChannel);
    SwitchMenu->addAction(pSetEnable);
    SwitchMenu->addSeparator();
    SwitchMenu->exec(QCursor::pos());
//    delete SwitchMenu;//防止内存泄露
    SwitchMenu->deleteLater();

    qDebug()<<__func__<<__LINE__<<__FILE__<<this->childCount();
    return ;
}
开发者ID:zhangzhiyong2016,项目名称:20160125CGI_Src,代码行数:33,代码来源:CGI_SCADA_DLL_TreeItemNET.cpp

示例3: contextMenuEvent

void Scene::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) {
  event->accept();
  QMenu* menu = new QMenu();
  QAction *ImageInfoAction = menu->addAction(QIcon(":/info.svg"),
                             tr("Image info"));
  connect(ImageInfoAction, SIGNAL(triggered()), this, SLOT(imageInfo()));
  menu->addSeparator();

  QAction* rotateCWAction = menu->addAction(QIcon(":/rotateCW.svg"),
                            tr("Rotate CW"));
  connect(rotateCWAction, SIGNAL(triggered()), this, SLOT(rotateCW()));

  QAction* rotateCCWAction = menu->addAction(QIcon(":/rotateCCW.svg"),
                             tr("Rotate CCW"));
  connect(rotateCCWAction, SIGNAL(triggered()), this, SLOT(rotateCCW()));

  QAction* rotateHalfAction = menu->addAction(QIcon(":/rotateCCW.svg"),
                              tr("Rotate 180°"));
  connect(rotateHalfAction, SIGNAL(triggered()), this, SLOT(rotateHalf()));
  QAction* detectOrientationAction = menu->addAction(QIcon(":/orientation.svg"),
                                                     tr("Detect orientation"));
  detectOrientationAction->setToolTip(
    tr("Page orientation detection (four 90 degree angles)"));
  connect(detectOrientationAction, SIGNAL(triggered()), this,
          SLOT(detectOrientation()));
  menu->exec(event->screenPos());
  menu->deleteLater();
}
开发者ID:,项目名称:,代码行数:28,代码来源:

示例4: slotContextMenu

void PublicHubs::slotContextMenu(){
    QItemSelectionModel *sel_model = treeView->selectionModel();
    QModelIndexList indexes = sel_model->selectedRows(0);

    if (indexes.isEmpty())
        return;

    if (proxy)
        std::transform(indexes.begin(), indexes.end(), indexes.begin(), [&](QModelIndex i) { return proxy->mapToSource(i); });

    WulforUtil *WU = WulforUtil::getInstance();

    QMenu *m = new QMenu();
    QAction *connect = new QAction(WU->getPixmap(WulforUtil::eiCONNECT), tr("Connect"), m);
    QAction *add_fav = new QAction(WU->getPixmap(WulforUtil::eiBOOKMARK_ADD), tr("Add to favorites"), m);
    QAction *copy    = new QAction(WU->getPixmap(WulforUtil::eiEDITCOPY), tr("Copy &address to clipboard"), m);

    m->addActions(QList<QAction*>() << connect << add_fav << copy);

    QAction *ret = m->exec(QCursor::pos());

    m->deleteLater();

    if (ret == connect){
        PublicHubItem * item = NULL;
        MainWindow *MW = MainWindow::getInstance();

        foreach (const QModelIndex &i, indexes){
            item = reinterpret_cast<PublicHubItem*>(i.internalPointer());

            if (item)
                MW->newHubFrame(item->data(COLUMN_PHUB_ADDRESS).toString(), "");

            item = NULL;
        }
开发者ID:,项目名称:,代码行数:35,代码来源:

示例5: 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

示例6: slotCustomContextMenu

void QMailTreeView::slotCustomContextMenu(const QPoint &pos)
{
    QMenu *menu = new QMenu;
    menu->addAction(tr("delete"), this, SLOT(slotDeleteMailClicked()));
    menu->exec(QCursor::pos());
    menu->deleteLater();
}
开发者ID:hechengjin,项目名称:cpp,代码行数:7,代码来源:mailtreeview.cpp

示例7: showContextMenu

void DataSourceView::showContextMenu(const QPoint &point)
{
	QModelIndex i = currentIndex();

	if (!i.isValid())
		return;

	QMenu *menu = new QMenu(this);

	menu->addAction(style()->standardIcon(QStyle::SP_DirOpenIcon), tr("Open"), this, SLOT(indexOpenPath()));
	menu->addAction(QIcon(":/gfx/tab-new.png"), tr("Open in a new tab"), this, SLOT(openInANewTab()));
	menu->addAction(QIcon(":/gfx/gohome.png"), tr("Set as working directory"), this, SLOT(setWorkingDirectory()));
	menu->addAction(style()->standardIcon(QStyle::SP_FileDialogNewFolder), tr("Create directory"), this, SLOT(createDirectory()));

	menu->addSeparator();

	menu->addAction(QIcon(":/gfx/document-edit.png"), tr("Edit"), this, SLOT(editDirectory()));
	menu->addAction(QIcon(":/gfx/list-remove.png"), tr("Delete"), this, SLOT(deleteDirectory()));

	menu->addSeparator();

	m_signalMapper->setMapping(menu->addAction(QIcon(":/gfx/external_programs/ZIMA-PTC-Cleaner.png"), tr("Clean with ZIMA-PTC-Cleaner"), m_signalMapper, SLOT(map())),
	                           ZimaUtils::internalNameForUtility(ZimaUtils::ZimaPtcCleaner));
	m_signalMapper->setMapping(menu->addAction(QIcon(":/gfx/external_programs/ZIMA-CAD-Sync.png"), tr("Sync with ZIMA-CAD-Sync"), m_signalMapper, SLOT(map())),
	                           ZimaUtils::internalNameForUtility(ZimaUtils::ZimaCadSync));
	m_signalMapper->setMapping(menu->addAction(QIcon(":/gfx/external_programs/ZIMA-PS2PDF.png"), tr("Convert postscript to PDF with ZIMA-PS2PDF"), m_signalMapper, SLOT(map())),
	                           ZimaUtils::internalNameForUtility(ZimaUtils::ZimaPs2Pdf));
	m_signalMapper->setMapping(menu->addAction(QIcon(":/gfx/external_programs/ZIMA-STEP-Edit.png"), tr("Edit step files with ZIMA-STEP-Edit"), m_signalMapper, SLOT(map())),
	                           ZimaUtils::internalNameForUtility(ZimaUtils::ZimaStepEdit));

	menu->exec(mapToGlobal(point));
	menu->deleteLater();
}
开发者ID:ZIMA-Engineering,项目名称:ZIMA-CAD-Parts,代码行数:33,代码来源:datasourceview.cpp

示例8: openAddMenu

void ViewportView::openAddMenu(bool view_commands)
{
    QMenu* m = new QMenu(this);

    if (view_commands && !angle_locked)
    {
        auto sub = new QMenu("View");

        connect(sub->addAction("Top"), &QAction::triggered,
                [=]{ this->spinTo(0, 0); });
        connect(sub->addAction("Bottom"), &QAction::triggered,
                [=]{ this->spinTo(0, -M_PI); });
        connect(sub->addAction("Left"), &QAction::triggered,
                [=]{ this->spinTo(M_PI/2, -M_PI/2); });
        connect(sub->addAction("Right"), &QAction::triggered,
                [=]{ this->spinTo(-M_PI/2, -M_PI/2); });
        connect(sub->addAction("Front"), &QAction::triggered,
                [=]{ this->spinTo(0, -M_PI/2); });
        connect(sub->addAction("Back"), &QAction::triggered,
                [=]{ this->spinTo(-M_PI, -M_PI/2); });

        m->addMenu(sub);
        m->addSeparator();
    }

    populateNodeMenu(m, view_scene->getGraph());

    m->exec(QCursor::pos());
    m->deleteLater();
}
开发者ID:pfelecan,项目名称:antimony-debian-packaging,代码行数:30,代码来源:view.cpp

示例9: showContextMenu

void InputTextWidget::showContextMenu(const QPoint &pos)
{
    QPoint globalPos = mapToGlobal(pos);

    QMenu *contextMenu = new QMenu(this);
    contextMenu->addAction(actionUndo);
    contextMenu->addAction(actionRedo);
    contextMenu->addSeparator();
    contextMenu->addAction(actionCut);
    contextMenu->addAction(actionCopy);
    contextMenu->addAction(actionPaste);

    // Disable cut and copy if nothing to copy
    if(textCursor().selection().isEmpty()) {
        actionCut->setDisabled(true);
        actionCopy->setDisabled(true);
    }

    // Disable paste if clipboard is empty
    if(QApplication::clipboard()->text().isEmpty()) {
        actionPaste->setDisabled(true);
    }

    contextMenu->exec(globalPos);
    contextMenu->deleteLater();

    actionCut->setEnabled(true);
    actionCopy->setEnabled(true);
    actionPaste->setEnabled(true);
}
开发者ID:Martijnvdc,项目名称:ProjectTox-Qt-GUI,代码行数:30,代码来源:inputtextwidget.cpp

示例10: slotContextMenu

void ToolBar::slotContextMenu(const QPoint &p){
    int tab = tabbar->tabAt(p);
    ArenaWidget *awgt = findWidgetForIndex(tab);

    if (!awgt){
        QMenu *m = new QMenu(this);
        QAction *act = new QAction(tr("Show close buttons"), m);

        act->setCheckable(true);
        act->setChecked(WBGET(WB_APP_TBAR_SHOW_CL_BTNS));

        m->addAction(act);

        if (m->exec(QCursor::pos())){
            WBSET(WB_APP_TBAR_SHOW_CL_BTNS, act->isChecked());
            tabbar->setTabsClosable(act->isChecked());
        }

        m->deleteLater();

        return;
    }

    QMenu *m = awgt->getMenu();

    if (m)
        m->exec(QCursor::pos());
}
开发者ID:eiskaltdcpp,项目名称:eiskaltdcpp,代码行数:28,代码来源:ToolBar.cpp

示例11: slotSidebarContextMenu

void SideBarView::slotSidebarContextMenu(){
    QItemSelectionModel *s_m = selectionModel();
    QModelIndexList selected = s_m->selectedRows(0);

    if (selected.size() < 1)
        return;

    SideBarItem *item = reinterpret_cast<SideBarItem*>(selected.at(0).internalPointer());

    QMenu *menu = NULL;
    
    if (item && item->childCount() > 0){
        menu = new QMenu(this);
        menu->addAction(WICON(WulforUtil::eiEDITDELETE), tr("Close all"));

        if (menu->exec(QCursor::pos())){
            QList<SideBarItem*> childs = item->childItems;

            for (const auto &child : childs){
                if (child && child->getWidget())
                    ArenaWidgetManager::getInstance()->rem(child->getWidget());
            }
        }
        
        menu->deleteLater();
    }
    else if (item && item->getWidget()){
        menu = item->getWidget()->getMenu();
        
        if (!menu && (item->getWidget()->state() & ArenaWidget::Singleton))
            return;

        if(!menu){
            menu = new QMenu(this);
            menu->addAction(WICON(WulforUtil::eiEDITDELETE), tr("Close"));

            if (menu->exec(QCursor::pos()))
                ArenaWidgetManager::getInstance()->rem(item->getWidget());
            
            menu->deleteLater();
        }
        else
            menu->exec(QCursor::pos());
    }
}
开发者ID:Acidburn0zzz,项目名称:eiskaltdcpp,代码行数:45,代码来源:SideBar.cpp

示例12: contextMenuEvent

void EffectSlider::contextMenuEvent(QContextMenuEvent* event)
{
  QMenu* contextMenu = new QMenu{this};

  contextMenu->addAction(m_addAutomAction);
  contextMenu->exec(event->globalPos());

  contextMenu->deleteLater();
}
开发者ID:OSSIA,项目名称:iscore-addon-audio,代码行数:9,代码来源:EffectSlider.cpp

示例13: buildMenu

int EditorToolBar::buildMenu(QMenu* pMenu, int indx)
{
    int index = indx;
    bool bSkip = true;
    WizEditorContextMenuItem* arrayData = contextMenuData();
    WizEditorContextMenuItem& curItem = arrayData[index];
    QMenu* pSubMenu = new QMenu(curItem.label, pMenu);

    while(1) {
        index++;

        WizEditorContextMenuItem& item = arrayData[index];
        if (item.label == "+") {
            break;

        } else if (item.label == "-") {
            pSubMenu->addSeparator();

        } else if (item.command != "+" && !item.execute.isEmpty()) {

            // special case
            if (m_editor->editorCommandQueryLink()
                    && item.label == WIZEDITOR_ACTION_LINK_INSERT) {
                continue;
            } else if (!m_editor->editorCommandQueryLink()
                       && item.label == WIZEDITOR_ACTION_LINK_EDIT) {
                continue;
            }

            if (!item.command.isEmpty()) {
                int value = m_editor->editorCommandQueryCommandState(item.command);
                if (value == -1) {
                    continue;
                }
            }

            bSkip = false;
            QString strSlot = "1" + item.execute + "()";
            m_actions[item.label] = pSubMenu->addAction(item.label, m_editor, strSlot.toUtf8());

        } else if (item.command.isEmpty() && item.execute.isEmpty()) {
            continue;
        } else {
            Q_ASSERT(0);
        }
    }

    if (!bSkip) {
        pMenu->addMenu(pSubMenu);
    } else {
        pSubMenu->deleteLater();
    }

    return index;
}
开发者ID:ChinaLongGanHu,项目名称:WizQTClient,代码行数:55,代码来源:wizEditorToolBar.cpp

示例14: contextMenuEvent

void MarkdownEditor::contextMenuEvent( QContextMenuEvent *e )
{
    // copy as Html
    e->accept();
    QMenu *menu = createStandardContextMenu();
    menu->addSeparator();
    QAction *spellCheckStatusAction = new QAction( tr( "Check spelling" ), menu );
    spellCheckStatusAction->setCheckable( true );
    spellCheckStatusAction->setChecked( !spellCheckLanguage.isEmpty() );
    menu->addAction( spellCheckStatusAction );
    QList<QAction *> spellCheckLanguageActions = addSpellCheckLanguageActions( menu );
    menu->addSeparator();
    copyAsHtmlAction->setEnabled( textCursor().hasSelection() );
    menu->addAction( copyAsHtmlAction );
    QList<QAction *> spellCheckActions;

    if ( e->reason() == QContextMenuEvent::Mouse && !textCursor().hasSelection() ) {
        setTextCursor( cursorForPosition( e->pos() ) );
        spellCheckActions = addSpellCheckActions( menu );
    }

    QAction *selected = menu->exec( e->globalPos() );

    if ( selected ) {
        if ( spellCheckActions.indexOf( selected ) != -1 ) {
            replaceTextInCurrentCursor( selected->text() );
        } else if ( selected == spellCheckStatusAction ) {
            if ( selected->isChecked() ) { //enable spell check
                spellCheckLanguage = conf->getSpellCheckLanguage();

                if ( conf->getSpellCheckLanguage().isEmpty() ) {
                    spellCheckLanguage = conf->getAllAvailableSpellCheckDictNames().first();
                }

                enableSpellCheck();
            } else {//disable spell check
                spellCheckLanguage.clear();
                disableSpellCheck();
            }
        } else if ( spellCheckLanguageActions.indexOf( selected ) != -1 &&
                    selected->data().canConvert( QVariant::String ) &&
                    !selected->data().toString().isEmpty() &&
                    selected->data().toString() != spellCheckLanguage ) {
            disableSpellCheck();
            spellCheckLanguage = selected->data().toString();
            enableSpellCheck();
        }
    }

    menu->deleteLater();
}
开发者ID:dyinuoh,项目名称:MdCharm,代码行数:51,代码来源:markdowneditor.cpp

示例15: execute

void ModelNodeContextMenu::execute(const QPoint &position, bool selectionMenuBool)
{
    QMenu* mainMenu = new QMenu();

    m_selectionContext.setShowSelectionTools(selectionMenuBool);
    m_selectionContext.setScenePosition(m_scenePos);


     QSet<ActionInterface* > factories =
             QSet<ActionInterface* >::fromList(QmlDesignerPlugin::instance()->designerActionManager().designerActions());

     populateMenu(factories, QByteArray(), mainMenu, m_selectionContext);

     mainMenu->exec(position);
     mainMenu->deleteLater();
}
开发者ID:qtproject,项目名称:qt-creator,代码行数:16,代码来源:modelnodecontextmenu.cpp


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