Hi,
I have a QScrollArea on my UI and I would like to put several things into it that would be lareger than the actual size of the scrollarea. So I defined a gridlayout into it and I put just some labels for testig.
My problem is clearly to be seen on the image attached. If the size of the scrollarea is smaller than the content then the content appears compressed (slided onto each other). However I would prefer to have a fixed sized gridlayout that is in this scrollarea and the scrollbars would appear if needed.
Here is the useful code part for this:
this
->lala
= new QLabel[9];
// lala stands for "layout's label" :) for(int i = 0; i < 3; i++)
{
for(int j = 0; j < 3; j++)
{
//setup the actual lala[]
lala
[3*i
+ j
].
setText(QString::number(3*i
+ j
));
lala[3*i + j].setFrameStyle(1);
lala[3*i + j].setLineWidth(1);
lala[3*i + j].setMinimumSize(100,100);
lala[3*i + j].setAlignment(Qt::AlignCenter);
//add lala[] to the gridlayout
gl->addWidget(&lala[3*i + j],i, j ,1,1,Qt::AlignCenter);
}
}
for(int i = 0; i < 3; i++)
{
gl->setColumnMinimumWidth(i,100); // no effect
gl->setRowMinimumHeight(i,100); // no effect
}
ui->scrollArea_2->setLayout(gl);
this->gl = new QGridLayout;
this->lala = new QLabel[9]; // lala stands for "layout's label" :)
QString s;
for(int i = 0; i < 3; i++)
{
for(int j = 0; j < 3; j++)
{
//setup the actual lala[]
lala[3*i + j].setText(QString::number(3*i + j));
lala[3*i + j].setFrameStyle(1);
lala[3*i + j].setLineWidth(1);
lala[3*i + j].setMinimumSize(100,100);
lala[3*i + j].setAlignment(Qt::AlignCenter);
//add lala[] to the gridlayout
gl->addWidget(&lala[3*i + j],i, j ,1,1,Qt::AlignCenter);
}
}
for(int i = 0; i < 3; i++)
{
gl->setColumnMinimumWidth(i,100); // no effect
gl->setRowMinimumHeight(i,100); // no effect
}
ui->scrollArea_2->setLayout(gl);
To copy to clipboard, switch view to plain text mode
1. why does setColumnMinimumWidth and setRowMinimumHeight has no effect?
2. how can I achieve this: the scrollbars sould appear below minimum sizes instead of collapsing?
Or should I use a completely other solution?
Szilvi
Bookmarks