1 Attachment(s)
Add one layout to another, peraint problem
Hi!
History of my question: I have some widget, it's created in QtDesigner. Widget has some controls and LAYOUT (FormLayuot for example).
Next, my app. load this widget from ui file, and replace default layout(added in QtDesigner) to my new.
Qt code of app.
//load widget from ui file, it has default layout, which added in QtDesigner
QFormBuilder builder;
QFile file("c:/wgt.ui");
file.open(QFile::ReadOnly);
QWidget *myWidget = builder.load(&file, 0);
file.close();
//save old layout
QLayout *oldLayout = myWidget->layout();
//add new grid-layout and insert old layout to new
QGridLayout *newLayout = new QGridLayout();
//add toolbar & menu bar to new grid-layout
QMenuBar *menuBar = new QMenuBar(myWidget);
QMenu *menuFile = new QMenu(tr("File"));
menuBar->addMenu(menuFile);
newLayout->setMenuBar(menuBar);
QToolBar *toolBar = new QToolBar(myWidget);
toolBar->addAction("dsd",0,"");
newLayout->addWidget(toolBar,0,0);
//insert old layout to new!
newLayout->addLayout(oldLayout,1,0);
myWidget->setLayout(newLayout);
//this->ui.mdiArea->addSubWindow(myWidget);
myWidget->show();
But after execute it has bug!
Re: Add one layout to another, peraint problem
What happens if you swap the layout adding?:
Code:
//insert old layout to new!
myWidget->setLayout(newLayout);
newLayout->addLayout(oldLayout,1,0);
Re: Add one layout to another, peraint problem
Re: Add one layout to another, peraint problem
no changes then I replace code