QScrollArea issues
-
Hey everyone,
I've been pulling my hair out over the QScrollArea for the past couple of days. What I want to do is this: I want to make an area on my window which will contain a variable number of rows of lineEdit and pushButton widgets. They are laid out in a gridLayout which I have put in a frame. That frame is put into a scrollArea so that when more rows are added, they scan be scrolled to.
I have had zero success using QtDesigner. I drag the scrollArea to the window, drag the frame to the scrollArea and then the gridLayout to the frame but when running, there are no scroll bars.
I have had some success programming it by hand.
@
scrollArea = new QScrollArea(tab_2);
fra_ds_segments = new QFrame;
gridLayout_2 = new QGridLayout(fra_ds_segments);fra_ds_segments->setLayout(gridLayout_2);
scrollArea->setWidget(fra_ds_segments);scrollArea->setGeometry(10, 210, 855, 201);
<<add lines of lineEdits and pushButtons to gridLayout_2>>
fra_ds_segments->resize(gridLayout_2->sizeHint());
@This seems to work OK though I'd rather calculate the size of scrollArea rather than hard-code it. I have hard-coded it to an area which doesn't need vertical scroll bars for 5 lines but will for any more than that. So as an aside, does anyone know how to calculate the proper width of a scrollArea to hold certain items an not need scroll bars?
The main issue is...how can I use a scrollArea this way within Designer?
Thanks!
-
Any progress with this? I'm having the same issue.
My situation also requires that the contents of the scroll area change dynamically. After a button push, widgets are supposed to be added to one of two groupboxes inside the scroll area. I believe I'm taking a fairly typical approach with Qt Designer:- Add Scroll Area to main widget.
- Drop groupboxes inside ScrollAreaContents (created automatically by Qt Designer when placing ScrollArea)
- Set Scroll Area layout with "Lay Out">"Lay Out Vertically"
- Set main widget layout likewise
Thanks
-
Have you tried "this":http://qt-project.org/doc/qt-5.0/qscrollarea.html#widgetResizable-prop ?
-
Hi,
I actually ended up giving up and went on to using a QTableView instead. It worked out better for me. Good luck.
[quote author="tim.sullivan" date="1344881283"]Any progress with this? I'm having the same issue.
My situation also requires that the contents of the scroll area change dynamically. After a button push, widgets are supposed to be added to one of two groupboxes inside the scroll area. I believe I'm taking a fairly typical approach with Qt Designer:- Add Scroll Area to main widget.
- Drop groupboxes inside ScrollAreaContents (created automatically by Qt Designer when placing ScrollArea)
- Set Scroll Area layout with "Lay Out">"Lay Out Vertically"
- Set main widget layout likewise
Thanks
[/quote]