Here's the problem:
#include <QtGui>
{
public:
{
menuBar()->addMenu("File");
menuBar()->addMenu("Edit");
menuBar()->addMenu("Tools");
menuBar()->addMenu("Help");
// change the color just to be able to see the widget
widget->setStyleSheet("background: rgba(255,0,0,128)");
// uncomment the following line and see the difference
// setCentralWidget(widget);
}
};
int main(int argc, char* argv[])
{
MainWindow window;
window.show();
return app.exec();
}
#include <QtGui>
class MainWindow : public QMainWindow
{
public:
MainWindow(QWidget* parent = 0) : QMainWindow(parent)
{
menuBar()->addMenu("File");
menuBar()->addMenu("Edit");
menuBar()->addMenu("Tools");
menuBar()->addMenu("Help");
QWidget* widget = new QWidget(this);
// change the color just to be able to see the widget
widget->setStyleSheet("background: rgba(255,0,0,128)");
// uncomment the following line and see the difference
// setCentralWidget(widget);
}
};
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
MainWindow window;
window.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks