PDA

View Full Version : How to resize a widget inside my centralWidget()?



gboelter
4th December 2009, 04:32
Hello!

I have created a QMainWidget using Qt's designer, wich has a centralWidget. The Layout of the centralWidget is set to grid-layout and resizing in the designer prview is doing well.

Then I have created a second Widget using the designer, which contains a frame and some other widgets. Layout is set to grid and resizing is doing well too in the designer preview.

And even resizing the MainWindow in my application is doing well too.

My problem now is, that my second widget - the one I like to show inside the centralWidget - don't resize if I resize my Mainwindow.



Home::Home ( MainWindow *pMainWindow )
: myMainWindow( pMainWindow )
{
frameHome = new QFrame( myMainWindow->centralwidget );

setupUi( frameHome );
}


What's wrong with that, why I cant resize the widget inside centralWidget?

I'm sure, it's a very simple thing but I can't figure it out.

May be it's to hot today ... ;)

Thanks in advance.

Guenther
Davao City, Philippines, Planet Earth, 35.3 °C

wysota
4th December 2009, 09:03
Add a layout to your central widget if it doesn't have one and place your frame inside that layout.

gboelter
4th December 2009, 09:48
Hello wysota,


Add a layout to your central widget if it doesn't have one and place your frame inside that layout.

that was my idea too, so I've tried it in many ways already but it don't work for me.

I have attached two screenshots.

For me it looks like, the centralWidget() has a layout. So I've tried this for example:



frameHome = new QWidget( myMainWindow->centralWidget() );
setupUi( frameHome );


I can resize the centralWidget, but not the content inside the centralWidget.

I guess, I understand something totally wrong .... :confused:

wysota
4th December 2009, 09:50
It may have a layout but you are not adding your widget to it.

gboelter
4th December 2009, 10:04
It may have a layout but you are not adding your widget to it.

wysota, you are the greatest!!!! :)

I've added one line to my code and now it's working.



frameHome = new QWidget( myMainWindow->centralWidget() );
myMainWindow->gridLayout->addWidget(frameHome, 0, 0, 1, 1);
setupUi( frameHome );


Thanks again for giving me the right idea.

Have a nice day.