Results 1 to 7 of 7

Thread: menubar Hide/remove

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: menubar Hide/remove

    I can't reproduce your problem.
    I don't see any menu bar if I remove the menu bar in designer it doesn't get showed in my window.
    Here is the generate ui_*.h file as you can see no menu bar is added.
    So probably there is not correlation between what you think you do, and what you really do.
    Did you remember to save your ui changes?
    Qt Code:
    1. class Ui_MainWindow
    2. {
    3. public:
    4. QWidget *centralwidget;
    5. QStatusBar *statusbar;
    6. QToolBar *toolBar;
    7.  
    8. void setupUi(QMainWindow *MainWindow)
    9. {
    10. if (MainWindow->objectName().isEmpty())
    11. MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
    12. MainWindow->resize(800, 600);
    13. centralwidget = new QWidget(MainWindow);
    14. centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
    15. MainWindow->setCentralWidget(centralwidget);
    16. statusbar = new QStatusBar(MainWindow);
    17. statusbar->setObjectName(QString::fromUtf8("statusbar"));
    18. MainWindow->setStatusBar(statusbar);
    19. toolBar = new QToolBar(MainWindow);
    20. toolBar->setObjectName(QString::fromUtf8("toolBar"));
    21. MainWindow->addToolBar(Qt::TopToolBarArea, toolBar);
    22.  
    23. retranslateUi(MainWindow);
    24.  
    25. QMetaObject::connectSlotsByName(MainWindow);
    26. } // setupUi
    27.  
    28. void retranslateUi(QMainWindow *MainWindow)
    29. {
    30. MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0, QApplication::UnicodeUTF8));
    31. toolBar->setWindowTitle(QApplication::translate("MainWindow", "toolBar", 0, QApplication::UnicodeUTF8));
    32. } // retranslateUi
    33.  
    34. };
    To copy to clipboard, switch view to plain text mode 
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  2. #2
    Join Date
    Sep 2008
    Posts
    54
    Thanks
    3
    Thanked 10 Times in 5 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    2

    Default Re: menubar Hide/remove

    In the end this is very poor documented and very easy to accomplish:

    Create menu:
    Qt Code:
    1. // Add help menu
    2. m_helpMenu = m_mainWindow->menuBar ()->addMenu (Tr ("&Help"));
    3.  
    4. m_helpMenu->setObjectName ("HelpMenu");
    5. m_helpMenu->setWindowTitle (Tr ("Help Menu"));
    6.  
    7. m_helpMenu->addAction (m_userManualAction);
    8. m_helpMenu->addAction (m_quickStartManualAction);
    9. m_helpMenu->addAction (m_aboutBoxAction);
    To copy to clipboard, switch view to plain text mode 


    Remove menu without destroy:
    Qt Code:
    1. m_mainWindow->menuBar ()->removeAction (m_helpMenu->menuAction ());
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Remove or hide title bar
    By tlerner in forum Qt Programming
    Replies: 3
    Last Post: 1st July 2013, 04:41
  2. Replies: 3
    Last Post: 4th May 2011, 14:29
  3. [QT] MenuBar
    By iVo1d in forum Qt Programming
    Replies: 2
    Last Post: 18th August 2010, 13:14
  4. How to hide/remove a addMenu() menu
    By MrGarbage in forum Qt Programming
    Replies: 2
    Last Post: 3rd August 2007, 23:32
  5. Using the menubar
    By Steve in forum Newbie
    Replies: 10
    Last Post: 27th February 2006, 15:59

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.