
Originally Posted by
Exeunt Omnes
PS One other thing has just occurred to me as possibly relevant. The resize() (or setGeometry(), or whatever) has no effect at all. The initial size of the QMainWindow is set in Qt Creator, after which it seems to be impossible to change it programmatically. This is why I thought I must be missing something. Any thoughts on this?
That sheds a different light: if you are actually unable to resize the window at all then removing the menu bar will move the content up but the lower bound of the window cannot follow. Since a QMainWindow is fully resizable by default then there is something you are doing to constrain your main window itself, or to its central widget or layout.
Does this stand-alone example behave properly when Unity steals the menu bar?
#include <QtGui>
Q_OBJECT
public:
connect(exitAct, SIGNAL(triggered()), qApp, SLOT(quit()));
QMenu *fileMenu
= menuBar
()->addMenu
(tr
("&File"));
fileMenu->addAction(exitAct);
frame
->setFrameStyle
(QFrame::Box);
setCentralWidget(frame);
}
};
int main(int argc, char *argv[])
{
MainWindow m;
m.show();
return app.exec();
}
#include "main.moc"
#include <QtGui>
class MainWindow: public QMainWindow {
Q_OBJECT
public:
MainWindow(QWidget *p = 0): QMainWindow(p) {
QAction *exitAct = new QAction(tr("&Exit"), this);
connect(exitAct, SIGNAL(triggered()), qApp, SLOT(quit()));
QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
fileMenu->addAction(exitAct);
QFrame *frame = new QFrame(this);
frame->setFrameStyle(QFrame::Box);
setCentralWidget(frame);
}
};
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MainWindow m;
m.show();
return app.exec();
}
#include "main.moc"
To copy to clipboard, switch view to plain text mode
Bookmarks