PDA

View Full Version : Main Window size problem



frenk_castle
19th December 2009, 23:58
I have the following problems. My application uses QStackedWidget as central widget. In QStackedWidget I have two widgets of different size that I alternate depending of what user choose.

First bigger problem:

Both widgets have height that is larger that the screen. Main Window automatically sets its size so that every thing fits but Main Window can't fit the screen and lower part are outside the screen. How can I set maximum size of my Main Window so it never gets bigger that what I set, and how can I put scroll bars so that user can scroll to areas that are not shown.

I spent some time reading the documentation and trying this and that, I managed to set the Vertical scroll bar but it doesn't matter because main window is always too big and because of that you can't scroll all the way. I can't seem to figure out what I am doing wrong.

Second problem:

Since one widget in QStackedWidget is bigger (it has bigger width) it seems that the starting size of Main window is always set according to the bigger (wider) widget. Even when I set that the smaller widget as the starting one main window is to big for it and this smaller widget looks bad. How can I force main window to shrink when this narrower widget is set and that expand when the wider widget is set.

In both problems I never what for main window to get bigger then some pre set size so that I avoid main window getting bigger than the screen. It would be nice if I could some how find out screens resolution and set maximum size of main window depending of the screen resolution. Also I would like both scroll bars to appear only if they are required but I can live with them being there all the time. Vertical one will always be nedded any way.

I would appreciate any help. I am sure that answer to my problems is in documentation some where but I failed to find it and honestly I don't know where to look. Even if you tell me read about function A or read about class B it helps me.

Thanks in advance.

nish
20th December 2009, 08:35
You need a QScrollArea as the central widget..
instead of setting the stackwidget as the centeral widget of mainwindow... just set a QScrollArea as the central widget and set the stackwidget as the child of QScrollArea..

frenk_castle
20th December 2009, 10:49
I spent an hour last night trying and trying. Now I made it work in minutes. Thanks MrDeath.