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 return deleted main menu bar?
Forum Updated to NodeBB v4.3 + New Features

How to return deleted main menu bar?

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

    I deleted the main menu bar out of my project, how do I return it?

    For the documentation:
    @QMenuBar * QMainWindow::menuBar() const @
    Returns the menu bar for the main window.

    However, I don't quite understand how to use it?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Alek Śmierciak
      wrote on last edited by
      #2

      I don't quite inderstand what you want it to do. From the QMainWindow::menuBar() doc entry:

      bq. Returns the menu bar for the main window. This function creates and returns an empty menu bar if the menu bar does not exist.

      This means that calling this function when you have no menuBar will yield you a new, empty one - you just need to specify your intentions regarding its use.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MuldeR
        wrote on last edited by
        #3

        Why do you use a QMainWindow at all? Maybe a QDialog would be better then.

        Anyway, I think you can remove the menubar like this:
        @QList<QMenuBar*> widgets = this->findChildren<QMenuBar*>();

        QMenuBar *current = NULL;

        foreach(current, widgets)
        {
        delete current;
        }@

        --

        EDIT: Sorry, I misunderstood. Though OP is looking to remove the menubar.

        My OpenSource software at: http://muldersoft.com/

        Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

        Go visit the coop: http://youtu.be/Jay...

        1 Reply Last reply
        0
        • L Offline
          L Offline
          Logical1
          wrote on last edited by
          #4

          I want the menu bar back on my form. How do I accomplish this?

          1 Reply Last reply
          0
          • M Offline
            M Offline
            MuldeR
            wrote on last edited by
            #5

            Please clarify! You mean programmatically or in the Qt Designer?

            I think you already found the answer for the former case. And in the later case:
            Rightclick → Create Menu Bar ;-)

            My OpenSource software at: http://muldersoft.com/

            Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

            Go visit the coop: http://youtu.be/Jay...

            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