Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Adding an action to the root of mainwindow menubar ?
Forum Updated to NodeBB v4.3 + New Features

Adding an action to the root of mainwindow menubar ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 641 Views 1 Watching
  • 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.
  • P Offline
    P Offline
    Paddle
    wrote on last edited by Paddle
    #1

    049d4d81-4b31-46ac-9016-e1d2e940a05a-image.png
    I'm trying to add 'Std_Worbench', a Freecad command (a wrapped action), to the main menubar.
    This Std_Worbench is basically an action group. Not a menu with submenu items.

    How can I add this directly to the root of the menubar? Because as you can see it's now in a submenu workbench/workbench/... which looks dumb.

    I'm trying to add the action directly to the menubar, but it doesn't work.

    Application::Instance->commandManager().addTo("Std_Workbench", menuBar);
    

    This is in fact calling down the line : QWidget::addAction(QAction)

    So it's equivalent to menuBar->addAction(Std_Workbench)

    Is that possible?

    Bonus question: How can I change the font size/bold and background color of only one menu item?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      On which OS are you on ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      P 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        On which OS are you on ?

        P Offline
        P Offline
        Paddle
        wrote on last edited by Paddle
        #3

        Hi @SGaist
        Edit: The main issue is solved. Std_Workbench was reimplementing addTo and was creating a sub menu in which it added the actions.
        So sorry for disturbing.

        However I'm still very interested to know how to customize the style of that particular menuBar item. I want to change :

        • Background color to blue
        • font color to white
        • Font size
        • Font to bold.
        • add an icon

        Also I need to change the menu title to the selected workbench name and icon when a workbench is selected.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          For the icon QMenu has the icon properly.

          For the rest either through a stylesheet or a proxy style.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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