Hi All,
I am trying to achieve something like the following:
flow_Layout_QPushButtons.jpg
Here's my code for it.
Window::Window()
{
FlowLayout *flowLayout = new FlowLayout();
flowWidget->setLayout(flowLayout);
int n=20;
QVector <QPushButton
*> buttons
(n
);
for (int ii=0;ii<n;ii++)
{
pb->setMinimumSize(200,200);
buttons.push_back(pb); // adding buttons to qvector
flowLayout->addWidget(pb);
}
scroll->setWidget(flowWidget);
a->setCentralWidget(scroll);
a->show();
setWindowTitle(tr("Flow Layout"));
}
Window::Window()
{
QMainWindow *a= new QMainWindow(this);
QWidget *flowWidget = new QWidget();
FlowLayout *flowLayout = new FlowLayout();
flowWidget->setLayout(flowLayout);
int n=20;
QVector <QPushButton *> buttons(n);
for (int ii=0;ii<n;ii++)
{
QPushButton * pb = new QPushButton(); // creating buttons
pb->setMinimumSize(200,200);
buttons.push_back(pb); // adding buttons to qvector
flowLayout->addWidget(pb);
}
QScrollArea *scroll =new QScrollArea();
scroll->setWidget(flowWidget);
a->setCentralWidget(scroll);
a->show();
setWindowTitle(tr("Flow Layout"));
}
To copy to clipboard, switch view to plain text mode
It seems like flowLayout is not working after the use of scrollArea widget. I want the content of window-2 to be displayed within window-1.
Please suggest how to achieve it?
Thanks!
Bookmarks