[Qt-interest] resizing widgets when user resizes mainwindow

Ulf-Alexander v. Ceumern-Lindenstjerna ceumern at vrmagic.com
Mon Dec 21 11:33:46 CET 2009


Hi,

I suggest you take a look at:
http://doc.trolltech.com/4.5/designer-layouts.html

You need to place a layout in all container widgets.

For your problem specifically:
Select the current page of your tabwidget and place a layout in it by
pressing the layout buttons in Designer. Do this for all pages of the
tabwidget. You can test your layout by pressing Ctrl-R and resizing your
window.

QLayout takes care of all resizing so you don't need to implement this
in your code.

Cheers, Ulf

> -----Original Message-----
> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-
> bounces at trolltech.com] On Behalf Of Mystical Groovy
> Sent: Sunday, December 20, 2009 7:05 PM
> To: qt-interest at trolltech.com
> Subject: [Qt-interest] resizing widgets when user resizes mainwindow
> 
> Hello all,
> 
> I'd like when the user resizes the main window of my app, the widgets
> inside the main window to be resized automatically too.
> 
> Ive set the sizePolicy of my main window to preferred.
> all the widgets inside the main window are placed inside a tab widget
> which is under the centralWidget.
> 
> this is what ive tried so far:
> 
> 	/* i suppose that when the user resizes the window, the height
> changes so i tried to check it with the following : */
> 
> 	if(!minimumSize().height == 800) //where 800 is the default
> height for the window
> 
> 	{
> 	 tabwidget->updateGeometry();
> 	// centralWidget->updateGeometry();
> 	// setupUi(this);
> 
> 	}
> 
> 
> after posting this question at qtcentre some folks told me to use
> layouts in my application to achieve that
> 
> i managed to lay out the tabwidget in my main window and when i resize
> the main window the tabwidget resizes along but not the widgets inside
> the tabwidget.
> i tried to lay out the widgets inside the tabwidget but as before it
> messes up my widget potitions and i cant set them in the way i want...
> 
> i hope you get the meaning,
> any help is appreciated :)





More information about the Qt-interest-old mailing list