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. Create custom QMenubar
Qt 6.11 is out! See what's new in the release blog

Create custom QMenubar

Scheduled Pinned Locked Moved Solved General and Desktop
qmenubarqmenucustom qwidgetcustomwidgetcustom
4 Posts 2 Posters 154 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.
  • Joe von HabsburgJ Offline
    Joe von HabsburgJ Offline
    Joe von Habsburg
    wrote last edited by
    #1

    Hello I would like to create custom qmenubar.

    It must to has qmenus and some buttons.

    1e9bd2d9-a082-4cd5-a9dc-b41b651a496e-image.png

    I tried demo with label but it is not what I would

    26ed63a2-d381-4892-a5a4-e9ed92165e39-image.png

    in ui
    beafba08-2a15-405a-9ebf-48a6469988b1-image.png

    MenuForm::MenuForm(QWidget *parent)
        : QMenuBar(parent)
        , ui(new Ui::MenuForm)
    {
        ui->setupUi(this);
    
        QMenu *menu1 = new QMenu("menut1");
        addMenu(menu1);
    
        QMenu *menu2 = new QMenu("menut2");
        addMenu(menu2);
    }
    

    How could i create like i draw?

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

      Hi,

      QWidgetAction comes to mind for that.

      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
      1
      • Joe von HabsburgJ Offline
        Joe von HabsburgJ Offline
        Joe von Habsburg
        wrote last edited by
        #3

        Thank you for reply.

        I want to be sure I understood correctly. Could I ask a few questions for that?

        Question 1: Should I use QWidgetAction instead of QMenuBar?
        Question 2: In the scenario where I continue to use QMenuBar, should I add QWidgetAction to QMenuBar?
        Question 3: In the scenario where I use QWidgetAction, should I add QMenus to QWidgetAction?
        Question 4: In the scenario where I use QWidgetAction, is there a way to edit visually through the UI file, or will these adding and editing operations be done entirely through code? Because editing visually is always better than editing with code (for GUI).

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote last edited by
          #4
          1. No
          2. Yes
          3. No
          4. I don't know and I disagree with you. Editing visually is just one way to do it. It's not better or worse than doing it 100% in code. It's a matter of personal taste and skills. Some people need or like to use Designer while other can go perfectly well without it.

          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
          3
          • Joe von HabsburgJ Joe von Habsburg has marked this topic as solved

          • Login

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