QUiLoader - QVLayoutBox adjust Size
-
I'm writing a program using Qt and C++ to reach the following result:
a) vMain : main area - QVBoxLayout for the widget;
b) hHeader: header area - QHBoxLayout to show two QLabels;
c) vCenter: central area to host another widget loaded from ab ui file;
@#include <QtGui\QApplication>
#include <QtUiTools/QUiLoader>
#include <QMenuBar>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QPushButton>
#include <QLabel>
#include <QFile>
#include <QMessageBox>int main(int argc, char *argv[])
{QApplication app(argc, argv);
QWidget *window = new QWidget(); //Create main layout QVBoxLayout *vMain = new QVBoxLayout(); window->setLayout(vMain); //Create header layout QHBoxLayout *hHeader = new QHBoxLayout; vMain->addLayout(hHeader); hHeader->addWidget(new QLabel("User")); hHeader->addWidget(new QLabel("Module")); //Create central area QVBoxLayout *vCenter = new QVBoxLayout; vMain->addLayout(vCenter); //Create a widget from an ui file QUiLoader loader; QFile file("c:\\Logon.ui"); file.open(QFile::ReadOnly); QWidget *myWidget = loader.load(&file, window); file.close(); vCenter->addWidget(myWidget); window->adjustSize(); window->show(); return app.exec();
}@
But the problem is that the main widget does not resize according the widget loaded from file.Does anybody have any about what is incorrect in this code?