QT Designer, How to have Scrolling available for Main Window
-
Hi,
I can't seem to figure this out. I'm trying to create a form that has several large Push buttons that users can click on to select things. On some Notebook PC's with low Display resolutions it can happen that the window won't fit on the screen and not all buttons are visible. What I want to happen in this situation is that the User can resize the Window so it fits on the Display, and that the Window gets Scrollbars so he can scroll to those buttons he can't see.In my point of view that should be how all Windows behave by default. If a window is large enough to display everything within it, no scrollbars, if it is resized so it is too small to display all it's contents, the scrollbars should appear.
I have tried using a Scroll area, added a layout to which I added the buttons, but when I use "Form, Preview in, Windows Style" and then resize the resulting Window, no Scrollbars appear and not all buttons are visible. If I set the Scrollbar properties to always be visible, they are shown, but they don't have any function.
Can anyone explain to me how to get this working?
I'm running the designer on Debian Testing...
Thanks for all help,
rindi -
@rindi
One thing: in your pic, each one of those "red no-entry" signs on your widgets indicates that you have not set a layout on the widget. And that can make things not right, even if this is not directly related to your issue. You should be able to right-click on those widgets --- either in this tree view or on the actual widget --- and select the Lay out entry to assign a layout to the widget. I would get all those done to see if it affects your problem. -
Hi and welcome to devnet,
From your description you have the following issue: you are trying to layout stuff on QScrollArea.
What you should do is create a QWidget, set a layout on it, put your buttons and the rest in that layout and then set that widget on the QScrollArea.
-
-
@rindi
One thing: in your pic, each one of those "red no-entry" signs on your widgets indicates that you have not set a layout on the widget. And that can make things not right, even if this is not directly related to your issue. You should be able to right-click on those widgets --- either in this tree view or on the actual widget --- and select the Lay out entry to assign a layout to the widget. I would get all those done to see if it affects your problem. -
@JonB said in QT Designer, How to have Scrolling available for Main Window:
One thing: in your pic, each one of those "red no-entry" signs on your widgets indicates that you have not set a layout on the widget. And that can make things not right, even if this is not directly related to your issue. You should be able to right-click on those widgets --- either in this tree view or on the actual widget --- and select the Lay out entry to assign a layout to the widget.
What if there is only one child in the widget without a layout? The "red no-entry" sign shows, but when you right-click on such a widget and select Layout, everything is greyed out.
-
@Calvin-H-C
That post was made 4 years ago! It's not 100% clear what you mean, but Designer has an unintuitive way of working if this is your case: if a widget has no children you cannot put a layout on it, it's greyed out. You have to add at least one child widget on the container widget, then you will be able to select a layout. You can even delete the child widget after that and leave the parent with a layout, you just have to have a child there in order to select a layout. -
@JonB I know it was an old thread, but the situation was what I was having with a QScrollView as a child to a central widget having a child that is a widget with scroll bars not showing.
When I tried adding a layout, all choices were greyed out. I recall reading somewhere that there must be at least TWO children to add a layout, which was what I was seeing. Your mentioning that it was possible to delete a child after adding a layout gave me an idea.
I added a second child and the choices for adding a layout were no longer greyed out, so I selected a layout and then deleted the unneeded child. That worked.
My problem is that with all the red circles gone, the scroll bars still don't work.
-
@Calvin-H-C
There has been noQScrollView
since Qt3. I have not heard of requiring two children for adding a layout, but there you are. Not everything needs a layout --- containers likeQScrollArea
do not, I don't think you should put one on them, and should not show the "no entry" sign without one. For scrolling issues I know thatQScrollArea
has a widgetResizable which often needs setting to true for scrolling/scrollbars to work right. Otherwise show a screenshot from Designer and paste (a minimal).ui
file and someone will doubtless comment.