Results 1 to 6 of 6

Thread: QMenuBar doesn't show up properly

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    387
    Thanks
    101
    Thanked 15 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default QMenuBar doesn't show up properly

    Hello!

    I have a problem with a QMenuBar. It doesn't show up properly. Instead of all the QMenu and QAction inside it, it only shows a ">>" symbol like this:
    menu.jpg

    I can press the symbol and a menu of menus shows up and everything works fine. But this is still a problem. I tried playing around with the size of the widget the QMenuBar is inside, removed all relevant style sheet entries and reduced the contents of the QMenuBar to a single QMenu with one QAction inside. Nothing helps. This happens only on one of two PCs where I tested it (Win XP does not work, Win7 works). The code to produce the menu looks like this:

    Qt Code:
    1. // Build the menu bar.
    2. QMenuBar* menuBar = new QMenuBar();
    3. QHBoxLayout* menuLayout = new QHBoxLayout(ui.menuWidget);
    4. menuLayout->setMargin(0);
    5. menuLayout->addWidget(menuBar);
    6. menuLayout->addStretch(1);
    7. ui.menuWidget->setLayout(menuLayout);
    8.  
    9. QMenu* fileMenu = menuBar->addMenu(tr("&File"));
    10.  
    11. QAction* saveStateAction = fileMenu->addAction(tr("&Save State"));
    12. saveStateAction->setToolTip(tr("Saves the state history."));
    13. saveStateAction->setShortcut(QKeySequence(tr("Ctrl+S")));
    14. connect(saveStateAction, SIGNAL(triggered()), this, SLOT(saveStateHistory()));
    15.  
    16. // ...and more QMenus and QActions follow.
    To copy to clipboard, switch view to plain text mode 


    Any advice?

    thanks,
    Cruz

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QMenuBar doesn't show up properly

    If you want a menu bar, maybe you could use QMainWindow instead? It already has a menu bar and proper layout to handle it.

    Cheers,
    _

Similar Threads

  1. why addSeparator() doesn't work on QMenuBar
    By yxmaomao in forum Qt Programming
    Replies: 2
    Last Post: 29th May 2008, 08:44
  2. Show QPixmap into QMenuBar
    By ^NyAw^ in forum Qt Programming
    Replies: 1
    Last Post: 28th May 2008, 11:03
  3. [B]How to show Pixmap on QMenuBar??[/B]
    By bigbigmoon in forum Newbie
    Replies: 2
    Last Post: 17th April 2007, 06:55
  4. show the backgroundpixmap of QMenuBar??-Qt-3.3.6
    By bigbigmoon in forum Newbie
    Replies: 10
    Last Post: 4th April 2007, 03:45
  5. where could QPopupMenu show besides QMenuBar !
    By bigbigmoon in forum Newbie
    Replies: 4
    Last Post: 2nd November 2006, 01:03

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.