I am adding three tables dynamically in widget containing table widget and labels, but nothing shows on screen, I have tried to do it with vertical layout but it does not expand if i add a new row, so not scrolling.
Is there any other way to get all three tables on a same page with scrolling.
QScrollArea *m_scrollArea =ui->scrollArea_Stats;
m_scrollArea->setWidgetResizable(true);
QWidget *area = new QWidget;
QVBoxLayout *vlay = new QVBoxLayout(m_scrollArea);
area->setLayout(vlay);
StatsWidget *objStatsWidget;
for(int i=0;i<2;i++)
{
objStatsWidget=new StatsWidget(ui->scrollArea_Stats);
vlay->addWidget(objStatsWidget);
}
m_scrollArea->setWidget(area);
here StatsWidget is my custom widget containing 2 lables at top and a table widget
I am adding three tables dynamically but page is not scrolling, vlay is not showing all tables it is just showing what it can show in a page without scrolling.
try rewrite the code as this:
EDIT: i made something like what you are trying to do some time ago..
so: create a custom
QWidgetwith aQVBoxLayoutas member.let’s call this object “widgetList”. then reimplement all method that you need, asaddWidget,takeAtetc.. using your layout as a listfinally set widgetList as widget for your scroll area..
let me know..
I made all this because
QWidgetListwas not enough easy to use and i needed something else that i have omitted here..I found my piece of code:
.cpp
this will be your new Widget with layout where to insert your custom widget..
then i put
widgetListas widget ofQScrollArea:everything works for me..
EDIT 2: i post my main that works good with my previous code: