本文整理汇总了C++中QMenu::removeAction方法的典型用法代码示例。如果您正苦于以下问题:C++ QMenu::removeAction方法的具体用法?C++ QMenu::removeAction怎么用?C++ QMenu::removeAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMenu
的用法示例。
在下文中一共展示了QMenu::removeAction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showContextMenu
void TextInputWidget::showContextMenu(const QPoint &pt)
{
QMenu *menu = createStandardContextMenu();
QList<QAction *> actions=menu->actions();
//hack menu
for(int i=0;i<actions.size();i++)
{
//qDebug()<<actions[i]->text();
if(actions[i]->text().contains("undo",Qt::CaseInsensitive))
{
menu->removeAction(actions[i]);
}
if(actions[i]->text().contains("redo",Qt::CaseInsensitive))
{
menu->removeAction(actions[i]);
}
if(actions[i]->text().contains("delete",Qt::CaseInsensitive))
{
menu->removeAction(actions[i]);
}
if(actions[i]->text().contains("cu",Qt::CaseInsensitive))
{
actions[i]->disconnect(SIGNAL(triggered(bool)));
connect(actions[i],SIGNAL(triggered(bool)),this,SLOT(cut()));
}
if(actions[i]->text().contains("paste",Qt::CaseInsensitive))
{
actions[i]->disconnect(SIGNAL(triggered(bool)));
connect(actions[i],SIGNAL(triggered(bool)),this,SLOT(paste()));
}
示例2: assert
/**
* View Menu
* Interface modification, load other interfaces, activate Extensions
* \param current, set to NULL for menu creation, else for menu update
**/
QMenu *VLCMenuBar::ViewMenu( intf_thread_t *p_intf, QMenu *current, MainInterface *_mi )
{
QAction *action;
QMenu *menu;
MainInterface *mi = _mi ? _mi : p_intf->p_sys->p_mi;
assert( mi );
if( !current )
{
menu = new QMenu( qtr( "&View" ), mi );
}
else
{
menu = current;
//menu->clear();
//HACK menu->clear() does not delete submenus
QList<QAction*> actions = menu->actions();
foreach( QAction *a, actions )
{
QMenu *m = a->menu();
if( a->parent() == menu ) delete a;
else menu->removeAction( a );
if( m && m->parent() == menu ) delete m;
}
}
示例3: RemoveMenus
void MainWindowMenuManager::RemoveMenus (const QMap<QString, QList<QAction*>>& menus)
{
for (const auto& menuName : menus.keys ())
{
QMenu *toRemove = nullptr;
if (menuName == "view")
toRemove = MenuView_;
else if (menuName == "tools")
toRemove = MenuTools_;
const auto& actions = menus [menuName];
if (toRemove)
for (const auto action : actions)
toRemove->removeAction (action);
else
{
for (auto action : Menu_->actions ())
if (action->text () == menuName)
{
Menu_->removeAction (action);
break;
}
}
}
}
示例4: removeMenuAction
void QtMenu::removeMenuAction(QMenu& qMenu, QAction& qAction)
{
qMenu.removeAction(&qAction);
auto children = qMenu.findChildren<QMenu*>(QString(), Qt::FindDirectChildrenOnly);
for (auto& child : children)
{
removeMenuAction(*child, qAction);
// we check actions.isEmpty rather than child.isEmpty as child.isEmpty doesnt include hidden actions
if (child->actions().isEmpty())
{
auto childAction = child->menuAction();
qMenu.removeAction(childAction);
child->deleteLater();
}
}
}
示例5: doUninstall
void IFPGUIModule::doUninstall()
{
QMenu* toolsMenu = mainWindow->getToolsMenu();
animViewerAction->setParent(NULL);
toolsMenu->removeAction(animViewerAction);
}
示例6: on_actionClearMenuRecentFiles_triggered
void MainWindow::on_actionClearMenuRecentFiles_triggered() {
QMenu* menu = ui->menuRecentFiles;
for (int i = menu->actions().size() - separatorAndMenuCount - 1; i >= 0; i--) {
menu->removeAction(menu->actions().at(i));
}
updateMenuState();
}
示例7: QWidget
VarView::VarView(QWidget *parent) :
QWidget(parent),
ui(new Ui::VarView)
{
ui->setupUi(this);
setWindowTitle(QString::fromUtf8("Переменные программы"));
VarModel *varModel = ModelManager::getInstance()->getVarModel();
varModel->setIsRefresh(false);
ui->table->setModel(varModel);
QMenu *menu = ui->table->getMenu();
menu->removeAction(ui->table->actionAdd);
menu->removeAction(ui->table->actionEdit);
menu->removeAction(ui->table->actionDel);
}
示例8: menuRemove
void ScriptToolbox::menuRemove(QObject * menu, QObject * action)
{
QMenu * m = qobject_cast<QMenu*>(menu);
QAction * act = qobject_cast<QAction*>(action);
if (!act)
{
QMenu * ma = qobject_cast<QMenu*>(action);
act = ma->menuAction();
}
if(m && act)
m->removeAction(act);
}
示例9: end_state_drawing_rectangle
/**
* @brief Finishes drawing a rectangle.
*/
void TilesetView::end_state_drawing_rectangle() {
QRect rectangle = current_area_item->rect().toRect();
if (!rectangle.isEmpty() &&
sceneRect().contains(rectangle) &&
get_items_intersecting_current_area().isEmpty() &&
model->is_selection_empty() &&
!is_read_only()) {
// Context menu to create a pattern.
QMenu menu;
EnumMenus<Ground>::create_actions(
menu, EnumMenuCheckableOption::NON_CHECKABLE, [=](Ground ground) {
QString pattern_id;
do {
++last_integer_pattern_id;
pattern_id = QString::number(last_integer_pattern_id);
} while (model->id_to_index(pattern_id) != -1);
emit create_pattern_requested(pattern_id, rectangle, ground);
});
// Put most actions in a submenu to make the context menu smaller.
QMenu sub_menu(tr("New pattern (more options)"));
int i = 0;
for (QAction* action : menu.actions()) {
Ground ground = static_cast<Ground>(action->data().toInt());
if (ground == Ground::TRAVERSABLE ||
ground == Ground::WALL) {
action->setText(tr("New pattern (%1)").arg(GroundTraits::get_friendly_name(ground)));
}
else {
menu.removeAction(action);
sub_menu.addAction(action);
}
++i;
}
menu.addMenu(&sub_menu);
menu.addSeparator();
menu.addAction(tr("Cancel"));
menu.exec(cursor().pos() + QPoint(1, 1));
}
scene->removeItem(current_area_item);
delete current_area_item;
current_area_item = nullptr;
initially_selected_items.clear();
start_state_normal();
}
示例10: addRecentFiles
void Controls::addRecentFiles(const QString &fileName)
{
QMenu *rf = m_ui->menuRecent_Models;
QStringList files;
{
QSettings settings;
settings.beginGroup("General");
int numFiles = settings.beginReadArray("RecentFiles");
for (int i = 0; i < numFiles; ++i)
{
settings.setArrayIndex(i);
QByteArray coded = settings.value("file").toByteArray();
files.append(QUrl::fromPercentEncoding(coded));
}
}
files.removeAll(fileName);
files.push_front(fileName);
if (files.size() > 10)
files.pop_back();
QAction *act;
while (rf->actions().count() > 0)
{
act = rf->actions().at(0);
rf->removeAction(act);
delete act;
}
for (int i = 0; i < files.count(); ++i)
{
act = new QAction(files.at(i), this);
connect(act, SIGNAL(triggered()),
this, SLOT(load()));
rf->addAction(act);
}
{
QSettings settings;
settings.beginGroup("General");
settings.beginWriteArray("RecentFiles", files.count());
for (int i = 0; i < files.count(); ++i)
{
settings.setArrayIndex(i);
QByteArray coded = QUrl::toPercentEncoding(files.at(i));
settings.setValue("file", coded);
}
settings.endArray();
settings.endGroup();
settings.sync();
}
}
示例11:
//@Override
/*public*/ void AudioTableAction::setMenuBar(BeanTableFrame* f)
{
QMenuBar* menuBar = f->menuBar();
// ResourceBundle rbapps = ResourceBundle.getBundle("apps.AppsBundle");
QList<QAction*> subElements = menuBar->actions();
QMenu* fileMenu = nullptr;
for (int i = 0; i < menuBar->actions().count(); i++)
{
//if (menuBar->actionAt(i) instanceof JMenu)
if(qobject_cast<QMenu*>(menuBar->actions().at(i)) != nullptr)
{
if( ((QMenu*) menuBar->actions().at(i))->title()==(tr("File")))
{
fileMenu = (QMenu*) menuBar->actions().at(i);
}
}
}
if (fileMenu == nullptr) {
return;
}
subElements = fileMenu->actions();
for (int i = 0; i < subElements.length(); i++)
{
QList<QAction*> popsubElements = ((QMenu*)subElements.at(i))->actions();
for (int x = 0; x < popsubElements.length(); x++)
{
// if (popsubElements[x] instanceof JMenuItem)
if(qobject_cast<QMenu*>(popsubElements.at(x))!= nullptr)
{
if (((QMenu*) popsubElements[x])->title()==(tr("Print Table")))\
{
QMenu* printMenu = ((QMenu*) popsubElements[x]);
fileMenu->removeAction((QAction*)printMenu);
break;
}
}
}
}
fileMenu->addAction(atp->getPrintItem());
}
示例12: createStandardContextMenu
//------------------------------------------------------------------------------
QMenu* LineEdit::createStandardContextMenu()
{
QMenu* popup = QLineEdit::createStandardContextMenu();
if ( ! undoRedoEnabled)
{
QList<QAction*> actions = popup->actions();
for (int i=0; i<actions.size(); ++i)
{
if (actions.at(i)->text().contains(tr("Undo"))
|| actions.at(i)->text().contains(tr("&Redo")))
{
popup->removeAction(actions.at(i));
}
}
}
return popup;
}
示例13: unloadPlugin
/** Unload a plugin by its name. */
bool PluginManager::unloadPlugin(const QString &absFilePath)
{
BasicPlugin *basic = _loadedPlugins.value(absFilePath);
for (QObject *dependency : _dependencies.values(basic->name())) {
if (QAction *action = qobject_cast<QAction*>(dependency)) {
QMenu *menu = qobject_cast<QMenu*>(action->parent());
menu->removeAction(action);
} else if (QMenu *menu = qobject_cast<QMenu*>(dependency)) {
delete menu;
}
}
_loadedPlugins.remove(absFilePath);
_dependencies.remove(basic->name());
basic->cleanUpBeforeDestroy();
delete basic;
basic = nullptr;
auto settings = SettingsPrivate::instance();
settings->disablePlugin(absFilePath);
return true;
}
示例14: contextMenu
void ChatView::contextMenu(QMenu *menu, const QWebHitTestResult &result)
{
menu->addSeparator();
const QUrl url = result.linkUrl();
if (url.scheme() == LS("chat") && url.host() == LS("channel"))
Hooks::ChannelMenu::bind(menu, ChatUrls::channel(url), Hooks::ChatViewScope);
else
Hooks::ChannelMenu::bind(menu, ChatClient::channels()->get(m_id), Hooks::ChatViewScope);
menu->addSeparator();
QMenu *display = menu->addMenu(SCHAT_ICON(Gear), tr("Display"));
display->addAction(m_seconds);
display->addAction(m_service);
developerMenu(display);
display->removeAction(pageAction(QWebPage::Reload));
menu->addAction(m_autoscroll);
menu->addSeparator();
ClientChannel channel = ChatClient::channels()->get(id());
if (channel && channel->data().value(LS("page")) == 1)
menu->addAction(m_reload);
else
menu->addAction(m_clear);
if (!result.isContentEditable()) {
menu->removeAction(pageAction(QWebPage::SelectAll));
menu->addAction(pageAction(QWebPage::SelectAll));
}
menu->removeAction(pageAction(QWebPage::Reload));
menu->removeAction(pageAction(QWebPage::InspectElement));
connect(menu, SIGNAL(triggered(QAction*)), SLOT(menuTriggered(QAction*)));
ChatViewHooks::contextMenu(this, menu, result);
}
示例15: actionFontMetrics
QMenu *TikzCommandInserter::getMenu(const TikzCommandList &commandList)
{
QMenu *menu = new QMenu(commandList.title, m_parentWidget);
const int numOfCommands = commandList.commands.size();
QAction *action = new QAction("test", menu);
int whichSection = 0;
// get left margin of the menu (to be added to the minimum width of the menu)
menu->addAction(action);
QFont actionFont = action->font();
actionFont.setPointSize(actionFont.pointSize() - 1);
QFontMetrics actionFontMetrics(actionFont);
int menuLeftMargin = menu->width() - actionFontMetrics.boundingRect(action->text()).width();
menu->removeAction(action);
int menuMinimumWidth = 0;
for (int i = 0; i < numOfCommands; ++i)
{
const QString name = commandList.commands.at(i).name;
if (name.isEmpty()) // add separator or submenu
{
if (commandList.commands.at(i).type == 0)
{
action = new QAction(menu);
action->setSeparator(true);
menu->addAction(action);
}
else // type == -1, so add submenu; this assumes that the i-th command with type == -1 corresponds with the i-th submenu (see getCommands())
{
menu->addMenu(getMenu(commandList.children.at(whichSection)));
++whichSection;
}
}
else // add command
{
action = new QAction(name, menu);
action->setData(commandList.commands.at(i).number); // link to the corresponding item in m_tikzCommandsList
action->setStatusTip(commandList.commands.at(i).description);
menuMinimumWidth = qMax(menuMinimumWidth, actionFontMetrics.boundingRect(commandList.commands.at(i).description).width());
connect(action, SIGNAL(triggered()), this, SLOT(insertTag()));
connect(action, SIGNAL(hovered()), this, SLOT(updateDescriptionMenuItem()));
menu->addAction(action);
}
}
// if the menu does not only contain submenus, then we add a menu item
// at the bottom of the menu which shows the description of the currently
// highlighted menu item
if (whichSection < menu->actions().size())
{
action = new QAction(this);
action->setSeparator(true);
menu->addAction(action);
action = new QAction(this);
QFont actionFont = action->font();
actionFont.setPointSize(actionFont.pointSize() - 1);
action->setFont(actionFont);
connect(action, SIGNAL(triggered()), this, SLOT(insertTag()));
menu->addAction(action);
// make sure that the menu width does not change when the content
// of the above menu item changes
menu->setMinimumWidth(menuMinimumWidth + menuLeftMargin);
}
return menu;
}