Results 1 to 4 of 4

Thread: Basic QMainWindow doesn't show menubar

  1. #1
    Join Date
    Apr 2010
    Posts
    77
    Thanks
    10
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Basic QMainWindow doesn't show menubar

    Hi Guys

    I've just started with QT and have created a QMainWindow in QT Designer. I've added several menuItems with actions to the menubar.
    I then create a subclass (MainWindow) inheriting from Ui::MainWindow and QMainWindow.
    Then in main, I create MainWindow and show it.

    Compiles fine and runs but only shows the mainWindow without the menubar.

    Am running Leopard on a Mac.

    What might I be doing wrong?

    Jeff

  2. #2
    Join Date
    Feb 2010
    Posts
    53
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Basic QMainWindow doesn't show menubar

    I had this problem I'm also a beginner, adding the snippet of code shown below on the constructor in the mainwindow.cpp file solved it for me.


    Qt Code:
    1. MainWindowImpl::MainWindowImpl( QWidget * parent, Qt::WFlags f)
    2. : QMainWindow(parent, f)
    3. {
    4. setupUi(this); // required so menus appear only window w/o it
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Basic QMainWindow doesn't show menubar

    Quote Originally Posted by Jeffb View Post
    Am running Leopard on a Mac.
    On Macs the menu bar is on top of the screen and not in the window.

  4. #4
    Join Date
    Apr 2010
    Posts
    77
    Thanks
    10
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    MacOS X

    Thumbs up

    @Master

    Of course it is.

    Been reading too many textbooks that are based on Windows - I forgot what my own operating system looks like.

    Thanks heaps
    Jeff

    @Novice

    Originally I forgot to put in setupUi(this) and the program ran but nothing showed up including the form.
    When I put it in, everything worked fine - I just didn't realise it - thanks again Master of Zen.

    Jeff
    Last edited by wysota; 14th April 2010 at 16:01.

Similar Threads

  1. QMainWindow and custom widget doesn't show
    By Peppy in forum Qt Programming
    Replies: 9
    Last Post: 26th December 2009, 15:09
  2. Can't click menubar items / QPixMap doesn't show
    By richardander in forum Qt Programming
    Replies: 1
    Last Post: 30th December 2008, 10:45
  3. Replies: 6
    Last Post: 20th August 2008, 20:21
  4. Replies: 5
    Last Post: 21st November 2007, 09:51
  5. Replies: 2
    Last Post: 23rd February 2006, 16:38

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.