adapting scrollarea when you expand or decrease intern widget
-
Hi,
Can you explain what do you mean by adapting the scroll area ?
-
okay, with picture it's more explicative
first i have this :
3 widgets "graph" in a scroll area.
with grow graph i expand the 3 widgets in the scroll area.void MainWindow::on_grow_clicked() { int w,h; w=2500; h=600; QSize grow_size(w,h); ui->graph->resize(grow_size); ui->graph2->resize(grow_size); ui->graph3->resize(grow_size); //ui->scrollAreaWidgetContents->update(); }
the 3 widgets grow correctly but :
it's not perfect, i would like this when i grow graph :
with the scroll vertical -
@Albator
You do not tell us how you are creating/adding your widgets. aQScrollArea
only accepts a single widget to scroll, you talk about your 3 widgets, how are you adding those on the scroll area?Further, we do not know what your
QScrollArea::setWidgetResizable()
setting is.https://stackoverflow.com/questions/12781407/how-do-i-resize-the-contents-of-a-qscrollarea-as-more-widgets-are-placed-inside may be useful reading for you.
-
@Albator
I don't know what code that generates. Did that create a "holding"QWidget
to drop your widgets onto? Did you put a layout onto that "holding" widget when you added your sub-widgets? Also what about thesetWidgetResizable()
setting? Did you look at the SO link? -
@Albator
That stuff look about right.
The SO (StackOverflow) link was thehttps://stackoverflow.com/questions/12781407/how-do-i-resize-the-contents-of-a-qscrollarea-as-more-widgets-are-placed-inside may be useful reading for you.
I think you should read that, though I believe you have done the necessary.
//ui->scrollAreaWidgetContents->update();
I think you should try
ui->scrollAreaWidgetContents->adjustSize()
in case that resolves.I admit at this point I'm not sure! I try playing about with scroll settings till they work :) I don't know why you are getting a horizontal scrollbar but not a vertical one.
-
I'll look at the SO link ;)
then it's just in case I enlarge the widgets during the application run with the "grow graph" button.By setting the minimunsize parameter of my graph widgets to very wide and very high without using the buttons, the scroll area works fine so it's probably possible.
parameters widgets graph :
and the result :
the problem it's just when i use the resize with button.
i will try with adjustsize :)
EDIT :
adjustsize() doesn't work -
I might be wrong but it looks like you are not using a layout on scrollAreaWidgetContents_2, are you ?
-
Then maybe another silly question: are you sure your widgets are put in that layout ?
-