Hi -
I am adding QActions to my menu dynamically when a dynamic library is loaded as a plugin. Items get added to a menu using the following funciton:
QAction* MainWindow
::createModuleMenuItem(const QString &text,
const QObject *receiver,
const char *member
) { return moduleMenu->addAction(text, receiver, member);
}
QAction* MainWindow::createModuleMenuItem(const QString &text, const QObject *receiver, const char *member) {
return moduleMenu->addAction(text, receiver, member);
}
To copy to clipboard, switch view to plain text mode
This method works fine for inserting items into menus. However I am having trouble removing items from said menus. I know there is a removeAction function for Menus, but it takes a QAction as an argument, and since I am loading my menu items dynamically, I don't have a name to pass as an arguement to the removeAction function.
In general, I can get items to load into a menu and remove them from a menu when the QAction has a name tied to it (as shown below), but I can't see to figure out how to do it with QActions added to menus without a statically defined name (as shown above).
load->setStatusTip(tr("Load a saved workspace"));
connect(load, SIGNAL(triggered()), this, SLOT(loadSettings()));
fileMenu->addAction(load);
fileMenu->removeAction(load)
QAction *load = new QAction(tr("&Load Workspace"), this);
load->setShortcuts(QKeySequence::Open);
load->setStatusTip(tr("Load a saved workspace"));
connect(load, SIGNAL(triggered()), this, SLOT(loadSettings()));
fileMenu->addAction(load);
fileMenu->removeAction(load)
To copy to clipboard, switch view to plain text mode
Any advice/help/guidance is appreciated. Thanks.
Bookmarks