dungsivn
23rd January 2008, 03:27
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
void MainWindow::createMenus()
{
//....
setMenuBar(new MenuBar(this))
}
and here is constructor of MenuBar class:
MenuBar::MenuBar(QWidget* parent):QMenuBar(parent)
{
gridLayout = new QGridLayout(this);
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
hboxLayout = new QHBoxLayout();
hboxLayout->setObjectName(QString::fromUtf8("hboxLayout"));
toolButton = new QToolButton(this);
toolButton->setObjectName(QString::fromUtf8("toolButton"));
hboxLayout->addWidget(toolButton);
pushButton_2 = new QPushButton(this);
pushButton_2->setObjectName(QString::fromUtf8("pushButton_2"));
hboxLayout->addWidget(pushButton_2);
pushButton_3 = new QPushButton(this);
pushButton_3->setObjectName(QString::fromUtf8("pushButton_3"));
hboxLayout->addWidget(pushButton_3);
spacerItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
hboxLayout->addItem(spacerItem);
lineEdit = new QLineEdit(this);
lineEdit->setObjectName(QString::fromUtf8("lineEdit"));
hboxLayout->addWidget(lineEdit);
setFixedHeight(50);
gridLayout->addLayout(hboxLayout, 0, 0, 1, 1);
this->setLayout(gridLayout);
this->show();
}
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!
Here is code:
// MainWindow is main class and called in main.cpp. This class contains toolbar, statusbar
void MainWindow::createMenus()
{
//....
setMenuBar(new MenuBar(this))
}
and here is constructor of MenuBar class:
MenuBar::MenuBar(QWidget* parent):QMenuBar(parent)
{
gridLayout = new QGridLayout(this);
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
hboxLayout = new QHBoxLayout();
hboxLayout->setObjectName(QString::fromUtf8("hboxLayout"));
toolButton = new QToolButton(this);
toolButton->setObjectName(QString::fromUtf8("toolButton"));
hboxLayout->addWidget(toolButton);
pushButton_2 = new QPushButton(this);
pushButton_2->setObjectName(QString::fromUtf8("pushButton_2"));
hboxLayout->addWidget(pushButton_2);
pushButton_3 = new QPushButton(this);
pushButton_3->setObjectName(QString::fromUtf8("pushButton_3"));
hboxLayout->addWidget(pushButton_3);
spacerItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
hboxLayout->addItem(spacerItem);
lineEdit = new QLineEdit(this);
lineEdit->setObjectName(QString::fromUtf8("lineEdit"));
hboxLayout->addWidget(lineEdit);
setFixedHeight(50);
gridLayout->addLayout(hboxLayout, 0, 0, 1, 1);
this->setLayout(gridLayout);
this->show();
}
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!