[SOLVED]QtabWidget, how to make it scrollable
-
Hi,
I'm sorry if I created a duplicate thread but I couldn't find anything on this thread in search so I'm posting this question.
I created a Tab widget using QT Designer and I want to make the contents in the tab area to be scrollable so my form will not be too long. Appreciate it if someone can help to advise on it.
Thank you -
Put a QScrollArea on the tab, and the widgets you want inside the scroll area
-
You don't make the tab widget scrollable, but instead you add a widget on the tab that provides the scrolling. Simply place a QScrollArea widget as your only widget on the tab, and place your form elements on that widget.
Better yet: design your forms in such a way that no scrolling is needed :)
-
ermm, i tried just that but it still doesn't show?
-
Without showing us what you did, it is hard for us to see what you did wrong...
-
sorry, but here's a snapshot i took.
http://i57.tinypic.com/14ncz2p.png
as you can see on the right, there are some widgets under the Scrollarea. I just kinda position the widgets under it and try to run it.
Am i missing something else? -
Try putting everyting in proper layouts.
-
Looks like scrollbars policy is Qt::ScrollBarAlwaysOff (if container of your widgets is is QScrollArea).It should be Qt::ScrollBarAsNeeded (default) or Qt::ScrollBarAlwaysOn , so then you'll get desired result.
-
yes, the scrollbar policy is set to Qt::ScrollBarAsNeeded. I changed it to Qt::ScrollBarAlwaysOn but it's not scrollable :(
-
strange, looks like controls parent isn't QScrollArea.
Have you tried same thing on QMainWindow (add QScrollArea + child controls) ? -
Hi,
I tested with just adding QScrollArea and child controls on the QMainWindow but the scrollbar doesn't appear too when it's being run. :O -
Then I really don't know what's up.
-
Andre has a good suggestion.
-
Thanks guys, it was because of the layout problem. Btw, everytime i click "Layout in a Form layout" the scroll area automatically resizes to a small box on the top left corner. Is there a way to prevent this?
-
Apply a layout at every level, including on the widget that contains the QScrollArea... Everywhere you see the Layout-with-a-red-crossed-circle icon in the Object Inspector should be looked at.
-
If you use layouts, you have to use layouts all the way:
- Every widget (except the top level one) has to be in a layout
- Every widget that contains other widgets has to have a layout.
Recursively.
-
Ok I understand. Thank Andre!