Results 1 to 2 of 2

Thread: menubar problem, help me!!

  1. #1
    Join Date
    Jun 2007
    Posts
    15
    Thanks
    2

    Default menubar problem, help me!!

    I created a small application and subclass QMenubar, this class has a layout with some buttons, textedit,... In mainwindow class, I used setMenubar(..) to replace the system menubar by one.

    Here is code:

    // MainWindow is main class and called in main.cpp. This class contains toolbar, statusbar
    Qt Code:
    1. void MainWindow::createMenus()
    2. {
    3. //....
    4.  
    5. setMenuBar(new MenuBar(this))
    6. }
    To copy to clipboard, switch view to plain text mode 

    and here is constructor of MenuBar class:

    Qt Code:
    1. MenuBar::MenuBar(QWidget* parent):QMenuBar(parent)
    2. {
    3.  
    4. gridLayout = new QGridLayout(this);
    5. gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
    6.  
    7. hboxLayout = new QHBoxLayout();
    8. hboxLayout->setObjectName(QString::fromUtf8("hboxLayout"));
    9.  
    10. toolButton = new QToolButton(this);
    11. toolButton->setObjectName(QString::fromUtf8("toolButton"));
    12.  
    13. hboxLayout->addWidget(toolButton);
    14.  
    15. pushButton_2 = new QPushButton(this);
    16. pushButton_2->setObjectName(QString::fromUtf8("pushButton_2"));
    17.  
    18. hboxLayout->addWidget(pushButton_2);
    19.  
    20. pushButton_3 = new QPushButton(this);
    21. pushButton_3->setObjectName(QString::fromUtf8("pushButton_3"));
    22.  
    23. hboxLayout->addWidget(pushButton_3);
    24.  
    25. spacerItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
    26.  
    27. hboxLayout->addItem(spacerItem);
    28.  
    29. lineEdit = new QLineEdit(this);
    30. lineEdit->setObjectName(QString::fromUtf8("lineEdit"));
    31.  
    32. hboxLayout->addWidget(lineEdit);
    33.  
    34.  
    35. setFixedHeight(50);
    36.  
    37. gridLayout->addLayout(hboxLayout, 0, 0, 1, 1);
    38. this->setLayout(gridLayout);
    39. this->show();
    40.  
    41. }
    To copy to clipboard, switch view to plain text mode 


    The problem is that: the toolbar of mainwindow is always above the subclass Menubar, hide the area of Menubar. I want the geometry of the toolbar is below the subclass Menubar.
    Any help? thanks!
    Last edited by dungsivn; 23rd January 2008 at 03:52.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: menubar problem, help me!!

    How does removing fixed height affect? I'd like to try, could you attach a compilable example?
    J-P Nurmi

Similar Threads

  1. Showing and hiding menubar
    By borges in forum Newbie
    Replies: 1
    Last Post: 23rd September 2007, 10:56
  2. QActions don't work with menubar hidden
    By Pepe in forum Qt Programming
    Replies: 1
    Last Post: 16th August 2007, 01:04
  3. menuBar() Problem
    By Cutey in forum Qt Programming
    Replies: 9
    Last Post: 25th January 2007, 11:50
  4. Replies: 2
    Last Post: 12th November 2006, 08:47
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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.