How to resize a widget inside my centralWidget()?
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.
Code:
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
Re: How to resize a widget inside my centralWidget()?
Add a layout to your central widget if it doesn't have one and place your frame inside that layout.
2 Attachment(s)
Re: How to resize a widget inside my centralWidget()?
Hello wysota,
Quote:
Originally Posted by
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:
Code:
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:
Re: How to resize a widget inside my centralWidget()?
It may have a layout but you are not adding your widget to it.
Re: How to resize a widget inside my centralWidget()?
Quote:
Originally Posted by
wysota
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.
Code:
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.