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. Menu not showing up in menuBar
Forum Updated to NodeBB v4.3 + New Features

Menu not showing up in menuBar

Scheduled Pinned Locked Moved General and Desktop
20 Posts 18 Posters 28.6k Views 3 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.
  • G Offline
    G Offline
    giesbert
    wrote on last edited by
    #2

    I just copied your code to my project and it works perfectly.

    Nokia Certified Qt Specialist.
    Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      ZapB
      wrote on last edited by
      #3

      Try doing a rebuild of your project. Sounds like you have a stale build.

      Nokia Certified Qt Specialist
      Interested in hearing about Qt related work

      1 Reply Last reply
      0
      • B Offline
        B Offline
        babazaroni
        wrote on last edited by
        #4

        Thanks guys, still no luck. I deleted the build folder and user settings and rebuilt. I guess I'll need to start with an existing demo app where the menus work and add in my app code.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on last edited by
          #5

          you could zip your complete project and put it to pastebin, but otherwise, I see no chance to look for a bug, as the posted code works.

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          1 Reply Last reply
          0
          • H Offline
            H Offline
            HuXiKa
            wrote on last edited by
            #6

            Works for me too.

            If you can find faults of spelling in the text above, you can keep them.

            1 Reply Last reply
            0
            • L Offline
              L Offline
              Loulou
              wrote on last edited by
              #7

              I had the same issue of the menu bar not showing (config: Qt 5.2 , ubuntu 13.10). This trick solved the issue:
              @menuBar()->setNativeMenuBar(false);@

              D 1 Reply Last reply
              0
              • F Offline
                F Offline
                fightling
                wrote on last edited by
                #8

                [quote author="Loulou" date="1387722347"]I had the same issue of the menu bar not showing (config: Qt 5.2 , ubuntu 13.10). This trick solved the issue:
                @menuBar()->setNativeMenuBar(false);@[/quote]

                Thank you that great & simple solution. Worked for me!

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  maalej
                  wrote on last edited by
                  #9

                  Thanks,

                  I encountered the same problem when I created a new QMainwindow project using the native MenuBar and adding some items to it.
                  The MenuBar does not appear after running the program, and appears only when double clicking the windoow to make it full screen.
                  the code line:
                  @menuBar()->setNativeMenuBar(false);// Trick to see native MenuBar@
                  You can say it is the trick to see the native MenuBar, but for me it has no sense especially the false thing. The question still remains why it does not appear in-spite automatic generation?

                  1 Reply Last reply
                  0
                  • W Offline
                    W Offline
                    willy27
                    wrote on last edited by
                    #10

                    [quote author="Loulou" date="1387722347"]I had the same issue of the menu bar not showing (config: Qt 5.2 , ubuntu 13.10). This trick solved the issue:
                    @menuBar()->setNativeMenuBar(false);@[/quote]

                    Thank you, It also worked for me on mac os !

                    ElvisE T 2 Replies Last reply
                    1
                    • L Loulou

                      I had the same issue of the menu bar not showing (config: Qt 5.2 , ubuntu 13.10). This trick solved the issue:
                      @menuBar()->setNativeMenuBar(false);@

                      D Offline
                      D Offline
                      DavidMc
                      wrote on last edited by
                      #11

                      Where would I add this code to get it to work? Not sure which file it has to go in. New to QT and any help would be appreciated :)

                      ? 1 Reply Last reply
                      0
                      • dheerendraD Online
                        dheerendraD Online
                        dheerendra
                        Qt Champions 2022
                        wrote on last edited by
                        #12

                        which platform you are trying ? If Ubuntu and Mac, platform do some intelligence. Just try to add few more actions like QAction("David") , QAction("Dheeru") like this. It will start showing up. Since you are default "Quit" and "Quit" is by default available. So it may not be showing up.

                        Dheerendra
                        @Community Service
                        Certified Qt Specialist
                        http://www.pthinks.com

                        1 Reply Last reply
                        4
                        • D DavidMc

                          Where would I add this code to get it to work? Not sure which file it has to go in. New to QT and any help would be appreciated :)

                          ? Offline
                          ? Offline
                          A Former User
                          wrote on last edited by
                          #13

                          @DavidMc Hi, add the following to your main.cpp:

                          QCoreApplication::​setAttribute(Qt::AA_DontUseNativeMenuBar)
                          

                          Same effect, just for all your menu bars.
                          Cheers!

                          A 1 Reply Last reply
                          1
                          • W willy27

                            [quote author="Loulou" date="1387722347"]I had the same issue of the menu bar not showing (config: Qt 5.2 , ubuntu 13.10). This trick solved the issue:
                            @menuBar()->setNativeMenuBar(false);@[/quote]

                            Thank you, It also worked for me on mac os !

                            ElvisE Offline
                            ElvisE Offline
                            Elvis
                            wrote on last edited by
                            #14

                            @willy27 It also affect my code.

                            1 Reply Last reply
                            0
                            • W willy27

                              [quote author="Loulou" date="1387722347"]I had the same issue of the menu bar not showing (config: Qt 5.2 , ubuntu 13.10). This trick solved the issue:
                              @menuBar()->setNativeMenuBar(false);@[/quote]

                              Thank you, It also worked for me on mac os !

                              T Offline
                              T Offline
                              tallia1
                              wrote on last edited by
                              #15

                              @willy27 Your temporary fix worked quite well. It's not pretty, but it does the job!!

                              1 Reply Last reply
                              0
                              • ? A Former User

                                @DavidMc Hi, add the following to your main.cpp:

                                QCoreApplication::​setAttribute(Qt::AA_DontUseNativeMenuBar)
                                

                                Same effect, just for all your menu bars.
                                Cheers!

                                A Offline
                                A Offline
                                abagu
                                wrote on last edited by
                                #16

                                I just ran into the same problem trying to follow the Qt5 tutorial from https://doc.qt.io/qt-5/qtwidgets-tutorials-notepad-example.html on MacOS Catalina (no menu bar mystery after building), which has no warnings about differences between platforms. This saved me some time before I delve into macextras

                                1 Reply Last reply
                                0
                                • A Offline
                                  A Offline
                                  astroonaut
                                  wrote on last edited by astroonaut
                                  #17

                                  Hi guys, very new into Qt, just got this workin on high sierra/PyCharm/PyQt 5.15.3. My menubar is called "menubar" => self.menubar.setNativeMenuBar(False)
                                  ...if you try to solve it from python side. Thanks a bunch!

                                  S 1 Reply Last reply
                                  0
                                  • A astroonaut

                                    Hi guys, very new into Qt, just got this workin on high sierra/PyCharm/PyQt 5.15.3. My menubar is called "menubar" => self.menubar.setNativeMenuBar(False)
                                    ...if you try to solve it from python side. Thanks a bunch!

                                    S Offline
                                    S Offline
                                    steelliberty
                                    wrote on last edited by
                                    #18

                                    @astroonaut Excellent .. works- Thanks

                                    1 Reply Last reply
                                    0
                                    • P Offline
                                      P Offline
                                      process detach
                                      wrote on last edited by
                                      #19

                                      Late bump, but one possibility if this is coming from PyQT - if the menu is not attributed to a class, it will be deleted by the garbage collection. changing menu = ... menuBar().addMenu('XX') to self.menu ..... worked for me.

                                      1 Reply Last reply
                                      0
                                      • enjoysmathE Offline
                                        enjoysmathE Offline
                                        enjoysmath
                                        wrote on last edited by
                                        #20

                                        Well, there's no more window bar nor app icons on Windows 10

                                        https://github.com/enjoysmath
                                        https://math.stackexchange.com/users/26327/exercisingmathematician

                                        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