Scrollable main window ... main widget not visible
This is a "newbie" question because I have a hard time with the way Qt does its interface. (I understand why it is the way it is but personally I find it a pain in the butt).
I have created my own custom "map" widget to be the main widget for my application. (in fact it is the ONLY visible widget on the entire main window besides the main menu and status bar) However I needed to make it scrollable because it is a "map" viewer that allows the user to zoom in and out. I need the map to resize every time the zoom is changed and I need it to fill the entire view (minus the status bar and menu bar at the top).
Here is what I have done so far.
In the UI designer I plopped a vertical layout on the main window. I tried to get it to resize to fill the window, but I am not sure if I did it correctly. It appears to only have the top left corner anchored in the viewable area. I am not even sure how this should be done. Then I plopped a scrollable area on that with the same uncertain "resize" action which seems to have had the opposite effect of making it size 1, 1. huh?
The application creates the "ui" and then creates the map widget dynamically with the "scrollablearea" as its parent widget. However, the map widget is not visible at all (possibly because of what I did with resizing in the designer). What am I doing wrong? Can anyone explain how to set up "full sized" widgets (that take up the entirety of the area in which they are placed) in the designer properly?
"I have a hard time with the way Qt does its interface. "
You mean layouts or ? Mainwindow is a bit special due to its
Anyway, try this:
(i think its how you want. map can be larger
than main and then have scrollbars)
make new std qwidget application.
open UI file
place scroll area
right click main form and select layout ( layout vert)
now scroll area follows mainwin
now place widget ( this is the custom map )
now right click scroll area, and select layout vert.
now select the widget (map), and adjust minimum size to 500,500
run the sample.
It took me some experimenting in Qt Designer but I found that my attempts to "maximize" the widget moved the widget out of the scrollarea container. I also had not set the widget as the object that the scrollarea was supposed to control. I fixed it by reorganizing the nested objects and setting the scroll area widget.