PDA

View Full Version : Problem in setting gridlayout.



Niamita
11th May 2011, 06:32
Hi
i am setting a gridlayout in frame which is child class of MainWindow , but the widget which i set on layout are not gett display.Where i am wrong.My code is


NewWindow::NewWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::NewWindow)
{
ui->setupUi(this);
this->setStyleSheet("background-color:gray");
QString string = "Home profile";
w1 = new MainWindow(string ,this);//Custom Buttons object
QString string1 = "Emergency Help";
w2 = new MainWindow(string1 ,this);//Custom Buttons object
QFrame *centralFrame=new QFrame(this);
centralFrame->setStyleSheet("background-color:blue");
this->setCentralWidget(centralFrame);
QGridLayout *layout= new QGridLayout(centralFrame);
layout->addWidget( w1,0,0);
layout->addWidget( w2,1,1);
centralFrame->setLayout(layout);
centralFrame->setGeometry(160,180,400,200);
}]

Thanks
Waiting for your reply.

MarekR22
11th May 2011, 08:32
You have attached centralFrame to NewWindow. So if NewWindow is smaller then about 160x180 then frame is out of view.

PS. Strange solution: MainWindow used as a child for other window/widget and managed by layout.