Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. QtCreator API: adding Menus to QtCreator works, but cannot enable Actions

QtCreator API: adding Menus to QtCreator works, but cannot enable Actions

Scheduled Pinned Locked Moved Qt Creator and other tools
1 Posts 1 Posters 3.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    markus.liebe
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved