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


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

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


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

示例1: contextMenuEvent

/*! \brief display the context Menu
 */
void ExtendedTableWidget::contextMenuEvent(QContextMenuEvent * event)
{
    qDebug() << Q_FUNC_INFO << event;
    qDebug() << "   " << event->pos();
    QTableWidgetItem *item = itemAt(event->pos());
    QAction *action;
    if (item) {
        event->accept();
        QMenu contextMenu( this );
        if (m_editable) {
            action = contextMenu.addAction(tr("&Remove"), this, SLOT(remove()));
            action->setProperty("row", row(item));
        }
        if (m_re_number.exactMatch(item->text())) {
            action = contextMenu.addAction(tr("&Dial"), this, SLOT(dialNumber()));
            action->setProperty("number", item->text());

            QMenu *transferMenu = new QMenu(tr("Direct &Transfer"), &contextMenu);
            QMenu *indirectTransferMenu = new QMenu(tr("&Indirect Transfer"), &contextMenu);
            UserInfo *ui = b_engine->getXivoClientUser();
            if (ui) {
                foreach (const QString phone, ui->phonelist()) {
                    const PhoneInfo * pi = ui->getPhoneInfo( phone );
                    if (pi) {
                        QMapIterator<QString, QVariant> it( pi->comms() );
                        while(it.hasNext()) {
                            it.next();
                            QMap<QString, QVariant> call = it.value().toMap();
                            // Add the transfer entry with the callerid name and num
                            QString text;
                            if (call.contains("calleridname")) {
                                text.append( call["calleridname"].toString() );
                                text.append(" : ");
                            }
                            text.append(call["calleridnum"].toString() );

                            action = transferMenu->addAction(text, this, SLOT(dtransfer()));
                            action->setProperty("chan", call["peerchannel"]);
                            action->setProperty("number", item->text());

                            action = indirectTransferMenu->addAction(text, this, SLOT(itransfer()));
                            action->setProperty("chan", call["thischannel"]);
                            action->setProperty("number", item->text());
                        }
                    }
                }
            }
            if (!transferMenu->isEmpty()) {
                contextMenu.addMenu(transferMenu);
            }
            if (!indirectTransferMenu->isEmpty()) {
                contextMenu.addMenu(indirectTransferMenu);
            }
        } else if(item->text().contains("@")) { // this is an email address
开发者ID:Eyepea,项目名称:xivo-gallifrey,代码行数:56,代码来源:extendedtablewidget.cpp

示例2: contextMenuEvent

void WebView::contextMenuEvent(QContextMenuEvent *event)
{
    QMenu *menu = new QMenu(this);

    QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos());

    if (!r.linkUrl().isEmpty()) {
        menu->addAction(tr("Open in New &Window"), this, SLOT(openLinkInNewWindow()));
        menu->addAction(tr("Open in New &Tab"), this, SLOT(openLinkInNewTab()));
        menu->addSeparator();
        menu->addAction(tr("Save Lin&k"), this, SLOT(downloadLinkToDisk()));
        menu->addAction(tr("&Bookmark This Link"), this, SLOT(bookmarkLink()))->setData(r.linkUrl().toString());
        menu->addSeparator();
        menu->addAction(tr("&Copy Link Location"), this, SLOT(copyLinkToClipboard()));
        if (page()->settings()->testAttribute(QWebSettings::DeveloperExtrasEnabled))
            menu->addAction(pageAction(QWebPage::InspectElement));
    }

    if (!r.imageUrl().isEmpty()) {
        if (!menu->isEmpty())
            menu->addSeparator();
        menu->addAction(tr("Open Image in New &Window"), this, SLOT(openImageInNewWindow()));
        menu->addAction(tr("Open Image in New &Tab"), this, SLOT(openImageInNewTab()));
        menu->addSeparator();
        menu->addAction(tr("&Save Image"), this, SLOT(downloadImageToDisk()));
        menu->addAction(tr("&Copy Image"), this, SLOT(copyImageToClipboard()));
        menu->addAction(tr("C&opy Image Location"), this, SLOT(copyImageLocationToClipboard()))->setData(r.imageUrl().toString());
    }

#ifdef WEBKIT_TRUNK // i.e. Qt 4.5, but not in Qt 4.5 yet
    if (menu->isEmpty())
        menu = page()->createStandardContextMenu();
#endif

    if (!menu->isEmpty()) {
        if (m_page->mainWindow()->menuBar()->isHidden()) {
            menu->addSeparator();
            menu->addAction(m_page->mainWindow()->showMenuBarAction());
        }

        menu->exec(mapToGlobal(event->pos()));
        delete menu;
        return;
    }
    delete menu;

    QWebView::contextMenuEvent(event);
}
开发者ID:ariya,项目名称:arora,代码行数:48,代码来源:webview.cpp

示例3: isEmpty

bool QMenuProto::isEmpty() const
{
  QMenu *item = qscriptvalue_cast<QMenu*>(thisObject());
  if (item)
    return item->isEmpty();
  return false;
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例4: aboutToShowFolderMenu

void BookmarksToolbar::aboutToShowFolderMenu()
{
    QMenu* menu = qobject_cast<QMenu*> (sender());
    if (!menu) {
        return;
    }

    menu->clear();
    QString folder = menu->title();

    QSqlQuery query;
    query.prepare("SELECT title, url, icon FROM bookmarks WHERE folder=?");
    query.addBindValue(folder);
    query.exec();
    while (query.next()) {
        QString title = query.value(0).toString();
        QUrl url = query.value(1).toUrl();
        QIcon icon = IconProvider::iconFromBase64(query.value(2).toByteArray());
        if (title.length() > 40) {
            title.truncate(40);
            title += "..";
        }

        Action* act = new Action(icon, title);
        act->setData(url);
        connect (act, SIGNAL(triggered()), p_QupZilla, SLOT(loadActionUrl()));
        connect (act, SIGNAL(middleClicked()), p_QupZilla, SLOT(loadActionUrlInNewTab()));
        menu->addAction(act);
    }

    if (menu->isEmpty()) {
        menu->addAction(tr("Empty"));
    }
}
开发者ID:unink88,项目名称:QupZilla,代码行数:34,代码来源:bookmarkstoolbar.cpp

示例5: customContextMenu

void DatabaseListWidget::customContextMenu(const QPoint& point)
{
	QMenu menu;

	QListWidgetItem *item = m_view->itemAt(point);
	QAction *newConnect=0, *switchDb=0;
	if(item) {
		newConnect = menu.addAction(tr("New connection"));
		if(m_canswitch)
			switchDb = menu.addAction(tr("Switch database"));
	}

	if(!menu.isEmpty())
		menu.addSeparator();

	QAction *refreshAct = menu.addAction(tr("Refresh"));

	QAction *a = menu.exec(m_view->mapToGlobal(point));
	if(a!=0) {
		if(a==refreshAct)
			m_connection->getDbList();
		else if(a==newConnect)
			emit newConnection(item->text());
		else if(a==switchDb)
			m_connection->switchDatabase(item->text());
	}
}
开发者ID:callaa,项目名称:KQueryBrowser,代码行数:27,代码来源:databaselistwidget.cpp

示例6: triggerMenu

bool CDiagramContextMenuHandler::triggerMenu(CDiagram *d, const QPoint &p)
{
    bool                        r = false;
    QMenu                       hostMenu;
    CDiagram::DiagramMode       mode;
    CDiagramContextMenu         *hostedMenu = NULL;
    QList<CDiagramContextMenu*> menus;

    mode = d->mode();
    if (m_menus.contains(mode))
        menus = m_menus[mode];

    if (menus.length() > 0)
    {
        for (int i = 0; i < menus.length(); ++i)
        {
            hostedMenu = menus.at(i);
            if (hostedMenu->support(d))
            {
                hostedMenu->reset(d);
                hostedMenu->apply(&hostMenu);
            }
        }

        if (!hostMenu.isEmpty())
        {
            hostMenu.exec(p);
            r = true;
        }
    }

    return r;
}
开发者ID:jetcodes,项目名称:JetMind,代码行数:33,代码来源:CDiagramContextMenuHandler.cpp

示例7: popup

bool MLModel::popup( const QModelIndex & index, const QPoint &point, const QModelIndexList &list )
{
    current_selection = list;
    current_index = index;
    QMenu menu;
    if( index.isValid() )
    {
        menu.addAction( QIcon( ":/menu/play" ), qtr(I_POP_PLAY), this, SLOT( popupPlay() ) );
        menu.addAction( QIcon( ":/menu/stream" ),
                        qtr(I_POP_STREAM), this, SLOT( popupStream() ) );
        menu.addAction( qtr(I_POP_SAVE), this, SLOT( popupSave() ) );
        menu.addAction( QIcon( ":/menu/info" ), qtr(I_POP_INFO), this, SLOT( popupInfo() ) );
        menu.addSeparator();
    }


    QIcon addIcon( ":/buttons/playlist/playlist_add" );
    menu.addSeparator();
    //menu.addAction( addIcon, qtr(I_PL_ADDF), THEDP, SLOT( simpleMLAppendDialog()) );
    //menu.addAction( addIcon, qtr(I_PL_ADDDIR), THEDP, SLOT( MLAppendDir() ) );
    //menu.addAction( addIcon, qtr(I_OP_ADVOP), THEDP, SLOT( MLAppendDialog() ) );

    if( index.isValid() )
    {
        menu.addAction( QIcon( ":/buttons/playlist/playlist_remove" ),
                        qtr(I_POP_DEL), this, SLOT( popupDel() ) );
        menu.addSeparator();
    }
    if( !menu.isEmpty() )
    {
        menu.exec( point ); return true;
    }
    else return false;
}
开发者ID:LDiracDelta,项目名称:vlc_censor_plugin,代码行数:34,代码来源:ml_model.cpp

示例8: contextMenuEvent

void WebView::contextMenuEvent(QContextMenuEvent* event)
{
	if (isLoading_) return;
	QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos());
	QMenu *menu;

	if (!r.linkUrl().isEmpty()) {
		if (r.linkUrl().scheme() == "addnick") {
			event->ignore();
			return;
		}
		menu = URLObject::getInstance()->createPopupMenu(r.linkUrl().toEncoded());
		//menu->addAction(pageAction(QWebPage::CopyLinkToClipboard));
	} else {
		menu = new QMenu(this);
		if (!page()->selectedText().isEmpty()) {
			menu->addAction(pageAction(QWebPage::Copy));
		} else {
			if (!menu->isEmpty()) {
				menu->addSeparator();
			}
			menu->addAction(pageAction(QWebPage::SelectAll));
		}
		if (settings()->testAttribute(QWebSettings::DeveloperExtrasEnabled)) {
			menu->addAction(pageAction(QWebPage::InspectElement));
		}
	}
	menu->addAction(pageAction(QWebPage::Reload));
	menu->exec(mapToGlobal(event->pos()));
	event->accept();
	delete menu;
}
开发者ID:akatov,项目名称:psi,代码行数:32,代码来源:webview.cpp

示例9: aboutToShowFolderMenu

void BookmarksToolbar::aboutToShowFolderMenu()
{
    QMenu* menu = qobject_cast<QMenu*> (sender());
    if (!menu) {
        return;
    }

    menu->clear();
    QString folder = menu->title();

    foreach (const Bookmark &b, m_bookmarksModel->folderBookmarks(folder)) {
        QString title = b.title;
        if (title.length() > 40) {
            title.truncate(40);
            title += "..";
        }

        Action* act = new Action(qIconProvider->iconFromImage(b.image), title);
        act->setData(b.url);
        connect(act, SIGNAL(triggered()), p_QupZilla, SLOT(loadActionUrl()));
        connect(act, SIGNAL(middleClicked()), p_QupZilla, SLOT(loadActionUrlInNewNotSelectedTab()));
        menu->addAction(act);
    }

    if (menu->isEmpty()) {
        menu->addAction(tr("Empty"))->setEnabled(false);
    }
}
开发者ID:Klaudit,项目名称:qupzilla,代码行数:28,代码来源:bookmarkstoolbar.cpp

示例10: showContextMenu

void pTableWidget::showContextMenu(const QPoint &pos)
{
    QMenu *contextMenu = new QMenu(this);
    foreach(QAction *a, actions())
        contextMenu->addAction(a);

    if(!contextMenu->isEmpty())
        contextMenu->exec(viewport()->mapToGlobal(pos));
}
开发者ID:qkthings,项目名称:qkwidget,代码行数:9,代码来源:ptablewidget.cpp

示例11:

QMenu *MvdMainWindow::createPopupMenu()
{
    QMenu *menu = QMainWindow::createPopupMenu();

    menu->addSeparator();
    if (!menu->isEmpty() && !menu->actions().last()->isSeparator())
        menu->addSeparator();
    menu->addAction(d->mA_LockToolBars);
    return menu;
}
开发者ID:hippydream,项目名称:movida,代码行数:10,代码来源:mainwindow.cpp

示例12: updateMenuVisibility

void QtMenu::updateMenuVisibility(QMenu& qMenu)
{
	auto children = qMenu.findChildren<QMenu*>(QString(), Qt::FindDirectChildrenOnly);
	for (auto& child : children)
	{
		updateMenuVisibility(*child);
	}

	qMenu.menuAction()->setVisible(!qMenu.isEmpty());
}
开发者ID:wgsyd,项目名称:wgtf,代码行数:10,代码来源:qt_menu.cpp

示例13: updateExamples

void GettingStartedWelcomePageWidget::updateExamples(const QString &examplePath,
                                                     const QString &demosPath,
                                                     const QString &sourcePath)
{

    QString demoXml = demosPath + "/qtdemo/xml/examples.xml";
    if (!QFile::exists(demoXml)) {
        demoXml = sourcePath + "/demos/qtdemo/xml/examples.xml";
        if (!QFile::exists(demoXml))
            return;
    }

    QMenuHash cppSubMenuHash;
    QMenuHash qmlSubMenuHash;

    const QString dropDownLabel = tr("Choose an Example...");
    QMenu *cppMenu = new QMenu(ui->cppExamplesButton);
    ui->cppExamplesButton->setMenu(cppMenu);
    QMenu *qmlMenu = new QMenu(ui->qmlExamplesButton);


    // let Creator's files take precedence
    QString localQmlExamplesXml =
            Core::ICore::instance()->resourcePath()+QLatin1String("/examplebrowser/qmlexamples.xml");

    QFile localDescriptions(localQmlExamplesXml);
    if (localDescriptions.open(QFile::ReadOnly)) {
        parseXmlFile(&localDescriptions, cppSubMenuHash, qmlSubMenuHash, examplePath, sourcePath);
    }

    QFile descriptions(demoXml);
    if (!descriptions.open(QFile::ReadOnly))
        return;

    ui->cppExamplesButton->setEnabled(true);
    ui->cppExamplesButton->setText(dropDownLabel);

    parseXmlFile(&descriptions, cppSubMenuHash, qmlSubMenuHash, examplePath, sourcePath);

    QList<QMenu*> cppSubMenus = cppSubMenuHash.values();
    qSort(cppSubMenus.begin(), cppSubMenus.end(), menuEntryCompare);
    QList<QMenu*> qmlSubMenus = qmlSubMenuHash.values();
    qSort(qmlSubMenus.begin(), qmlSubMenus.end(), menuEntryCompare);

    foreach (QMenu *menu, cppSubMenus)
        cppMenu->addMenu(menu);
    foreach (QMenu *menu, qmlSubMenus)
        qmlMenu->addMenu(menu);

    if (!qmlMenu->isEmpty()) {
        ui->qmlExamplesButton->setMenu(qmlMenu);
        ui->qmlExamplesButton->setEnabled(true);
        ui->qmlExamplesButton->setText(dropDownLabel);
    }
}
开发者ID:NoobSaibot,项目名称:qtcreator-minimap,代码行数:55,代码来源:gettingstartedwelcomepagewidget.cpp

示例14: contextMenuEvent

void QToasterBrowserLCD::contextMenuEvent(QContextMenuEvent * cme)
{
  if(mpCtxMenuProvider)
  {
    QMenu ctxMenu;
    QPoint globalPos = mapToGlobal(cme->pos());
    mpCtxMenuProvider->createMenu(ctxMenu);
    if(!ctxMenu.isEmpty())
      ctxMenu.exec(globalPos);
  }
}
开发者ID:damiangr,项目名称:Toaster,代码行数:11,代码来源:QToasterBrowserLCD.cpp

示例15: openContextMenu

void TaskTreeView::openContextMenu(TreeModel::Item *gItem,
                                   const QPoint &globalPos) {
  TaskTreeModel::Item *item = static_cast<TaskTreeModel::Item *>(gItem);
  TaskTreeModel *m          = static_cast<TaskTreeModel *>(model());
  // m->setSelected(item->createIndex());
  if (item->getDepth() == 1) {
    static QMenu globalMenu;
    if (globalMenu.isEmpty()) {
      const std::vector<QAction *> &actions = m_mainViewer->getActions();
      assert(!actions.empty());
      int i;
      for (i = 0; i < actions.size(); i++) {
        globalMenu.addAction(actions[i]);
        if (i == 1 || i == 3 || i == 6) globalMenu.addSeparator();
      }
    }
    globalMenu.exec(globalPos);
  } else if (item->getDepth() > 1) {
    static QMenu menu;
    if (menu.isEmpty()) {
      bool ret = true;
      QAction *action;
      action = new QAction(tr("Start"), this);
      ret =
          ret && connect(action, SIGNAL(triggered(bool)), m, SLOT(start(bool)));
      menu.addAction(action);
      action = new QAction(tr("Stop"), this);
      ret =
          ret && connect(action, SIGNAL(triggered(bool)), m, SLOT(stop(bool)));
      menu.addAction(action);
      action = new QAction(tr("Remove"), this);
      menu.addAction(action);
      ret = ret &&
            connect(action, SIGNAL(triggered(bool)), m, SLOT(remove(bool)));
      assert(ret);
    }
    menu.exec(globalPos);
  }
开发者ID:walkerka,项目名称:opentoonz,代码行数:38,代码来源:tasksviewer.cpp


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