[Solved] How to add dynamically a widget into a scrollarea [qt4] ?
-
Hello,
Here my code :
@
QScrollArea *frame_scroll = new QScrollArea(this);
QWidget container = new QWidget;
m_lpWidgetVboxLayout = new QVBoxLayout;
QCustomWdg lpCustomWdg = new QCustomWdg();
m_lpWidgetVboxLayout->addWidget( lpCustomWdg );
container->setLayout(m_lpWidgetVboxLayout);
frame_scroll->setWidget(container);
@This works fine, but when I call by a slot the following code :
@
void addNewCustomWdg()QCustomWdg* lpCustomWdg = new QCustomWdg();
m_lpWidgetVboxLayout->addWidget(m_lpCustomWdg);
m_lpVariantDiseaseWdg->show();
@The new custom wdg added in the container widget (which is the centralwidget of the scrollarea), override the first custom widget. It seem that the centralwidget has a fixed size and can not expanding. How to solve that ?
Thank
Xavier
-
Hi,
Ok I found the function which resize automatically the central widget of the QScrollArea when new widgets are added into.
@
frame_scroll->setWidgetResizable(true);
@do the job !