QtCreator API: adding Menus to QtCreator works, but cannot enable Actions
-
Hi there,
I have a plugin that adds a new Menu to QtCreators MenuBar. The Actions in the MenuBar are displayed but not enabled. I do not know why. Do you have any hints?
(Using QtCreator 2.1.0)
Here is the code:
@bool TestMenuPlugin::initialize(const QStringList& args, QString *errMsg){
Q_UNUSED(args);
Q_UNUSED(errMsg);// Fetch the action manager Core::ActionManager* am = Core::ICore::instance()->actionManager(); // Create the TestMenu Core::ActionContainer* ac = am->createMenu("TestMenuPlugin.TestMenuMenu"); ac->menu()->setTitle("&Test"); Core::Context context(TestMenu::Constants::C_TESTMENU); Core::Command* cmdTest = am->registerAction(new QAction(this),"TestPlugin.Test",context); cmdTest->action()->setText("Test"); cmdTest->action()->setEnabled(true); // Add TestPlugin menu to the menubar am->actionContainer(Core::Constants::MENU_BAR)->addMenu(ac); QMenu* windowMenu = am->actionContainer(Core::Constants::M_HELP)->menu(); QMenuBar* menuBar = am->actionContainer(Core::Constants::MENU_BAR)->menuBar(); menuBar->insertMenu(windowMenu->menuAction(),ac->menu());
//Trying to enable the action
ac->menu()->setEnabled(true);// Add the "Test" action to the TestPlugin Menu ac->addAction(cmdTest); // Connect the action connect(cmdTest->action(),SIGNAL(triggered()),this,SLOT(startSth())); addAutoReleasedObject(new TestMenuOptionPaneLister(m_fileSettings));
return true;
}@Regards,
Markus