Hi.
I am trying to display many elements, derived widgets, in a frame.
When I add just a few items scrollbar looks ok.
but when adding more elements, more than real size elements are compressed and vertical scroll bar not appear.
SearchResults
::SearchResults(QWidget *parent
) : ui(new Ui::SearchResults)
{
ui->setupUi(this);
scrollWidget
= new QWidget(parent
);
}
SearchResults::SearchResults(QWidget *parent) :
QFrame(parent),
ui(new Ui::SearchResults)
{
ui->setupUi(this);
gLayout = new QGridLayout(parent);
scrollWidget = new QWidget(parent);
}
To copy to clipboard, switch view to plain text mode
void SearchResults::setData()
{
ui
->scrollArea
->setBackgroundRole
(QPalette::Light);
int size = K_list::instance()->DetailList.size();
gLayout->setSpacing(10);
ui->scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
resultWidget *rw[size];
int cont;
for(cont=0;cont<size;cont++)
{
rw[cont] = new resultWidget(this);
rw[cont]->setData( K_list::instance()->DetailList.at(cont) );
rw[cont]->connect();
gLayout->addWidget(rw[cont]);
// appear compressed
}
ui->scrollArea->setWidget(scrollWidget);
scrollWidget->setLayout(gLayout);
show();
}
void SearchResults::setData()
{
ui->scrollArea->setBackgroundRole(QPalette::Light);
int size = K_list::instance()->DetailList.size();
gLayout->setSpacing(10);
ui->scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
resultWidget *rw[size];
int cont;
for(cont=0;cont<size;cont++)
{
rw[cont] = new resultWidget(this);
rw[cont]->setData( K_list::instance()->DetailList.at(cont) );
rw[cont]->connect();
gLayout->addWidget(rw[cont]);
// appear compressed
}
ui->scrollArea->setWidget(scrollWidget);
scrollWidget->setLayout(gLayout);
show();
}
To copy to clipboard, switch view to plain text mode
Thanks for any advice
Bookmarks