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. How to make the title visible for QMainWindow
Forum Update on Monday, May 27th 2025

How to make the title visible for QMainWindow

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 1.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.
  • L Offline
    L Offline
    lingan
    wrote on last edited by lingan
    #1

    I find that if menu is created on a QMainWindow, then its title text will be covered by the menus.
    I create menu bar like this:
    QMenuBar *menuBar = new QMenuBar();
    this->setMenuBar(menuBar);
    menuBar->addMenu("blabla");
    ...
    Then the created window is like this
    |x-o menu1 menu2 menu3|
    | this is tool bar________|
    |__________________|

    But what I want is like this:
    |x-o window title |
    |menu1 menu2 menu3 |
    |this is tool bar________|
    |__________________|

    How to make the title visible given there are menus?
    Thanks in advance!

    aha_1980A 2 Replies Last reply
    0
    • L lingan

      I find that if menu is created on a QMainWindow, then its title text will be covered by the menus.
      I create menu bar like this:
      QMenuBar *menuBar = new QMenuBar();
      this->setMenuBar(menuBar);
      menuBar->addMenu("blabla");
      ...
      Then the created window is like this
      |x-o menu1 menu2 menu3|
      | this is tool bar________|
      |__________________|

      But what I want is like this:
      |x-o window title |
      |menu1 menu2 menu3 |
      |this is tool bar________|
      |__________________|

      How to make the title visible given there are menus?
      Thanks in advance!

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi @lingan,

      which platform are you using? And which Qt version?

      Qt has to stay free or it will die.

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

        Hi,

        To add to @aha_1980, QMainWindow already provides a menu bar when calling the menuBar function.

        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
        • L lingan

          I find that if menu is created on a QMainWindow, then its title text will be covered by the menus.
          I create menu bar like this:
          QMenuBar *menuBar = new QMenuBar();
          this->setMenuBar(menuBar);
          menuBar->addMenu("blabla");
          ...
          Then the created window is like this
          |x-o menu1 menu2 menu3|
          | this is tool bar________|
          |__________________|

          But what I want is like this:
          |x-o window title |
          |menu1 menu2 menu3 |
          |this is tool bar________|
          |__________________|

          How to make the title visible given there are menus?
          Thanks in advance!

          aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi @lingan,

          Now I found what I was searching for.

          It's: menuBar->setNativeMenuBar(false);

          Docu: http://doc.qt.io/qt-5/qmenubar.html#nativeMenuBar-prop

          Qt has to stay free or it will die.

          L 1 Reply Last reply
          1
          • aha_1980A aha_1980

            Hi @lingan,

            Now I found what I was searching for.

            It's: menuBar->setNativeMenuBar(false);

            Docu: http://doc.qt.io/qt-5/qmenubar.html#nativeMenuBar-prop

            L Offline
            L Offline
            lingan
            wrote on last edited by
            #5

            @aha_1980 Your way works!
            Thank you so much!
            The platform is Ubuntu 17.04 and QT is of 5.7. Looks the default style of Ubuntu is like this.

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

              Just be aware that you are "breaking integration" with the desktop environment you use which might not be appreciated by your application users.

              You would get the same behaviour on e.g. macOS where the main menu is at the top of the screen and not on your application windows.

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

              aha_1980A 1 Reply Last reply
              1
              • SGaistS SGaist

                Just be aware that you are "breaking integration" with the desktop environment you use which might not be appreciated by your application users.

                You would get the same behaviour on e.g. macOS where the main menu is at the top of the screen and not on your application windows.

                aha_1980A Offline
                aha_1980A Offline
                aha_1980
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @SGaist, you are right.

                but at least Qt's Ubuntu/Unity integration has some bugs, so that QtCreator uses the non-native menu nowadays.

                Qt has to stay free or it will die.

                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