PDA

View Full Version : Resize button with window and layout



Radhika
6th January 2016, 09:06
I have Grid layout within that I have scrollArea where I am creating dynamic buttons, layout is within the centralWidget , When I resize (shrink , expand ) i want to resize my layout as well as button inside that .
How can I do that
I have tried adjustSize and setSizePolicy fixed and expanding but nothing works on layout
when I shrink the window button are hidden in stand of it I want it to be shrink with window size

ChrisW67
6th January 2016, 20:33
In all likelihood you have not applied the layout to the widget (i.e. myCentralWidget->setLayout(myGridLayout) ). Hard to say as we see no code.

Radhika
7th January 2016, 04:53
QWidget *w = new QWidget(this);
QGridLayout *grid = new QGridLayout();
ui->scrollArea->setWidget(w);
// this->setFixedSize(this->geometry().width(),this->geometry().height());


QMap<int,QPushButton*> mapp;
for(row=0;row <= 49 ;row++)
{

QPushButton *pb = new QPushButton(w);
grid->addWidget(pb, row/4, row%4);
pb->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expa nding);

}

w->setLayout(grid);


Here it is

when I have tried
centralWidget()->setLayout(grid);
it ll shrink with window size but it wont fit in to the layout