adapting scrollarea when you expand or decrease intern widget
-
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 verticalwrote on 4 Aug 2020, 09:30 last edited by JonB 8 Apr 2020, 09:31@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.
-
wrote on 4 Aug 2020, 09:38 last edited by
I added it from the mainwindows.ui design interface and drop the widgets in the scroll area.
-
I added it from the mainwindows.ui design interface and drop the widgets in the scroll area.
wrote on 4 Aug 2020, 09:41 last edited by JonB 8 Apr 2020, 09:41@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? -
wrote on 4 Aug 2020, 09:49 last edited by
-
okay so :
1-
when i create a scroll area with the design interface I don't know how to look at the code it created.
2-
yes, in the scroll area i have put a vertical layout.
3-
is enable
4-
What is SO link ?sorry in advance for my ignorance !
wrote on 4 Aug 2020, 10:06 last edited by JonB 8 Apr 2020, 10:07@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.
-
wrote on 4 Aug 2020, 11:51 last edited by Albator 8 Apr 2020, 13:00
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.
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 ?
-
wrote on 5 Aug 2020, 07:09 last edited by
-
wrote on 2 Sept 2020, 07:48 last edited by
i up the post
-
Lifetime Qt Championwrote on 2 Sept 2020, 18:17 last edited by SGaist 9 Feb 2020, 18:18
Then maybe another silly question: are you sure your widgets are put in that layout ?
-
wrote on 3 Sept 2020, 14:49 last edited by
to be sure I did a test I changed the shape layout to see if the widgets would follow the modification.
And yes if I change the layout vertically my widgets adapt and the same for other formats, which proves that the widgets are in this layout.