本文整理汇总了C++中QMenu::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ QMenu::clear方法的具体用法?C++ QMenu::clear怎么用?C++ QMenu::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMenu
的用法示例。
在下文中一共展示了QMenu::clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: kmt
/**
* NOTE: we assume kate is installed
*/
void KMoreToolsTest2::test_buildMenu_ShowConfigureMenuItem()
{
{
KMoreTools kmt(_("unittest-kmoretools/2"));
const auto kateApp = kmt.registerServiceByDesktopEntryName(_("org.kde.kate"));
// porcelain: other (interactive) tests will reuse the kmt id so we make sure that
// no user configurment disburbs this test:
const auto menuBuilder = kmt.menuBuilder(_("porcelain"));
menuBuilder->addMenuItem(kateApp);
QMenu menu;
menuBuilder->buildByAppendingToMenu(&menu); // == KMoreTools::ConfigureDialogAccessible_Always
qDebug() << menuBuilder->menuStructureAsString(true);
QVERIFY(menuAtLeastOneActionWithText(&menu, _("Configure..."))); // "Kate", "Separator", "Configure..."
{
menu.clear();
menuBuilder->buildByAppendingToMenu(&menu, KMoreTools::ConfigureDialogAccessible_Defensive);
QVERIFY(menuAtLeastNoActionWithText(&menu, _("Configure...")));
}
}
{
KMoreTools kmt(_("unittest-kmoretools/2"));
const auto kateApp = kmt.registerServiceByDesktopEntryName(_("org.kde.kate"));
const auto mynotInstalledApp = kmt.registerServiceByDesktopEntryName(_("mynotinstalledapp"));
const auto menuBuilder = kmt.menuBuilder(_("porcelain"));
menuBuilder->addMenuItem(kateApp);
menuBuilder->addMenuItem(mynotInstalledApp);
QMenu menu;
menuBuilder->buildByAppendingToMenu(&menu); // == KMoreTools::ConfigureDialogAccessible_Always
auto doAssert = [](QMenu* menu) {
QCOMPARE(menu->actions().count(), 3); // "Kate", "Separator", "More..."
auto moreMenu = menu->actions()[2]->menu();
QCOMPARE(moreMenu->actions().count(), 4); // "Not-installed-section", "Not installed app", "Separator", "Configure menu..."
auto configureMenu = moreMenu->actions()[3];
QCOMPARE(configureMenu->data().toString(), QString(_("configureItem")));
};
doAssert(&menu);
{
menu.clear();
menuBuilder->buildByAppendingToMenu(&menu, KMoreTools::ConfigureDialogAccessible_Defensive);
doAssert(&menu); // = same as _Always because there is one not-installed item
}
}
}
示例2: 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);
}
}
示例3: updateRecentFileList
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void StandardSIMPLViewApplication::updateRecentFileList(const QString& file)
{
SIMPLViewMenuItems* menuItems = SIMPLViewMenuItems::Instance();
for (int i = 0; i < m_SIMPLViewInstances.size(); i++)
{
SIMPLView_UI* window = m_SIMPLViewInstances[i];
if (NULL != window)
{
QMenu* recentFilesMenu = menuItems->getMenuRecentFiles();
QAction* clearRecentFilesAction = menuItems->getActionClearRecentFiles();
// Clear the Recent Items Menu
recentFilesMenu->clear();
// Get the list from the static object
QStringList files = QRecentFileList::instance()->fileList();
foreach(QString file, files)
{
QAction* action = new QAction(recentFilesMenu);
action->setText(QRecentFileList::instance()->parentAndFileName(file));
action->setData(file);
action->setVisible(true);
recentFilesMenu->addAction(action);
connect(action, SIGNAL(triggered()), this, SLOT(openRecentFile()));
}
recentFilesMenu->addSeparator();
recentFilesMenu->addAction(clearRecentFilesAction);
}
示例4: slotFixOpenWithMenu
void KateFileTree::slotFixOpenWithMenu()
{
QMenu *menu = (QMenu*)sender();
menu->clear();
KTextEditor::Document *doc = model()->data(m_indexContextMenu, KateFileTreeModel::DocumentRole).value<KTextEditor::Document *>();
if (!doc) return;
// get a list of appropriate services.
KMimeType::Ptr mime = KMimeType::mimeType(doc->mimeType());
//kDebug(13001) << "mime type: " << mime->name();
QAction *a = 0;
KService::List offers = KMimeTypeTrader::self()->query(mime->name(), "Application");
// for each one, insert a menu item...
for(KService::List::Iterator it = offers.begin(); it != offers.end(); ++it)
{
KService::Ptr service = *it;
if (service->name() == "Kate") continue;
a = menu->addAction(KIcon(service->icon()), service->name());
a->setData(service->entryPath());
}
// append "Other..." to call the KDE "open with" dialog.
a = menu->addAction(i18n("&Other..."));
a->setData(QString());
}
示例5: setToolbarItemState
void ZLQtApplicationWindow::setToolbarItemState(ZLToolbar::ItemPtr item, bool visible, bool enabled) {
QAction *action = myActions[&*item];
if (action != 0) {
action->setEnabled(enabled);
action->setVisible(visible);
}
switch (item->type()) {
default:
break;
case ZLToolbar::Item::MENU_BUTTON:
{
ZLToolbar::MenuButtonItem &buttonItem = (ZLToolbar::MenuButtonItem&)*item;
shared_ptr<ZLPopupData> data = buttonItem.popupData();
if (!data.isNull() && (data->id() != myPopupIdMap[&buttonItem])) {
myPopupIdMap[&buttonItem] = data->id();
QToolButton *button = myMenuButtons[&buttonItem];
QMenu *menu = button->menu();
menu->clear();
const size_t count = data->count();
for (size_t i = 0; i < count; ++i) {
menu->addAction(new ZLQtRunPopupAction(menu, data, i));
}
}
break;
}
}
}
示例6: 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"));
}
}
示例7: UnInstall_MainMenu
void MenuManager::UnInstall_MainMenu()
{
QMenu* pMenu = m_pMainWnd->menuGameObject;
if(pMenu)
{
pMenu->clear();
pMenu->menuAction()->setVisible(false);
}
pMenu = m_pMainWnd->menuComponent;
if(pMenu)
{
pMenu->clear();
pMenu->menuAction()->setVisible(false);
}
}
示例8: Install_MainMenu
void MenuManager::Install_MainMenu()
{
UnInstall_MainMenu();
QMenu* pMenu = m_pMainWnd->menuGameObject;
pMenu->clear();
Install_Menu_GameObject(pMenu);
pMenu->menuAction()->setVisible(true);
pMenu = m_pMainWnd->menuComponent;
pMenu->clear();
Install_Menu_Component(pMenu);
pMenu->menuAction()->setVisible(true);
}
示例9: setupMenu
void setupMenu() {
menuTypes->clear();
if (typeFlags.testFlag(KBibTeX::tfPlainText)) {
QAction *action = menuTypes->addAction(iconForTypeFlag(KBibTeX::tfPlainText), i18n("Plain Text"), menuTypesSignalMapper, SLOT(map()));
menuTypesSignalMapper->setMapping(action, KBibTeX::tfPlainText);
}
if (typeFlags.testFlag(KBibTeX::tfReference)) {
QAction *action = menuTypes->addAction(iconForTypeFlag(KBibTeX::tfReference), i18n("Reference"), menuTypesSignalMapper, SLOT(map()));
menuTypesSignalMapper->setMapping(action, KBibTeX::tfReference);
}
if (typeFlags.testFlag(KBibTeX::tfPerson)) {
QAction *action = menuTypes->addAction(iconForTypeFlag(KBibTeX::tfPerson), i18n("Person"), menuTypesSignalMapper, SLOT(map()));
menuTypesSignalMapper->setMapping(action, KBibTeX::tfPerson);
}
if (typeFlags.testFlag(KBibTeX::tfKeyword)) {
QAction *action = menuTypes->addAction(iconForTypeFlag(KBibTeX::tfKeyword), i18n("Keyword"), menuTypesSignalMapper, SLOT(map()));
menuTypesSignalMapper->setMapping(action, KBibTeX::tfKeyword);
}
if (typeFlags.testFlag(KBibTeX::tfSource)) {
QAction *action = menuTypes->addAction(iconForTypeFlag(KBibTeX::tfSource), i18n("Source Code"), menuTypesSignalMapper, SLOT(map()));
menuTypesSignalMapper->setMapping(action, KBibTeX::tfSource);
}
if (typeFlags.testFlag(KBibTeX::tfVerbatim)) {
QAction *action = menuTypes->addAction(iconForTypeFlag(KBibTeX::tfVerbatim), i18n("Verbatim Text"), menuTypesSignalMapper, SLOT(map()));
menuTypesSignalMapper->setMapping(action, KBibTeX::tfVerbatim);
}
}
示例10: updateRecent
void MainWindow::updateRecent()
{
// update the display
QMenu *menu = actionR_ecent->menu();
menu->clear();
int i=1;
QAction *action;
for (QStringList::iterator it=slRecent.begin(); it != slRecent.end(); it++)
{
QFileInfo file(*it);
if (file.exists())
{
// file exists, so we add it into the menu
action = menu->addAction(QString("&%1 ").arg(i)+file.fileName());
// mapping
smMapper->setMapping(action,i);
connect(action,SIGNAL(triggered()),smMapper,SLOT(map()));
action->setStatusTip(*it);
i++;
if (i == RECENT_NUMBER)
{
// deletes all remaining files in the list
slRecent.erase(it,slRecent.end());
break;
}
}
else
{
// mark the list item to be deleted
(*it) = "";
}
}
// delete empty items from the list
slRecent = slRecent.filter(QRegExp(".+"));
}
示例11: prepareMenu
void DefaultProxyAction::prepareMenu()
{
QMenu *menu = qobject_cast<QMenu *>(sender());
if (!menu)
return;
menu->clear();
NetworkProxy defaultProxy = m_networkProxyManager->defaultProxy();
QAction *proxyAction = menu->addAction(tr(" - No proxy - "));
// this parenting allows proxyActions to be removed on menu->clear() whats prevents memory leak
QActionGroup *proxyActions = new QActionGroup(proxyAction);
proxyActions->addAction(proxyAction);
proxyAction->setCheckable(true);
if (!defaultProxy)
proxyAction->setChecked(true);
populateMenu(menu, proxyActions, defaultProxy);
menu->addSeparator();
QAction *editProxyConfigurationAction = menu->addAction(tr("Edit proxy configuration..."));
connect(editProxyConfigurationAction, SIGNAL(triggered()), this, SLOT(editProxyConfiguration()));
}
示例12: resetColorMnu
void FormStyle::resetColorMnu()
{
mnuReset.clear();
if ( ReadOnly )
return;
mnuReset.addAction( Texts[127] /* Resetuj kolor */, this, SLOT( resetColor() ) );
mnuReset.popup(QCursor::pos());
}
示例13: l_clear
static int l_clear(lua_State* L)
{
QMenu* c = lua_tomenu(L, 1);
if(!c) return 0;
c->clear();
return 0;
}
示例14: update
void MenuBarManager::update( SMenuPanel *menu )
{
QMenu *mn = hash.value( menu );
mn->clear();
for( int i=0 ; i<menu->count() ; i++ )
mn->addAction( menu->at(i) );
}
示例15: clear
void KLanguageButtonPrivate::clear()
{
ids.clear();
popup->clear();
if ( !staticText ) {
button->setText( QString() );
}
}