Qt Creator: How to make Label widget scale with the window?

I'm a .NET developer and try to play with Qt and have encountered a problem.

In Visual Studio, I can make a Label control dock = Fill, so it will fill the form with the label. As the size of the window change, it will change the size of the label.

How do i do that in Qt? (I'm using Qt Creator)

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I suggest learning about layout.
My best guess for this solution is to put your label in Layout that will solve your problem
geoffryfAuthor Commented:
Thanks for your response

Can you please give me a more clear direction as to how to approach this problem? I'm really lost as I used to Visual Studio way of docking controls

Okay, you are using Qt Designer where you drag the controls and put on the Form/widget.
Just press control and click on your label and form ( i mean to say select form and label) then on the top of the designer you will see some 4 icons like vertical layout or horizontal etc. choose your desired lay out and click that. These layout stuff should also be available when you right click (you should see womething like put in the layout option)
Or if you are coding manually then you can put following.

following code may not be compile error free, just typing to give you some hint.
void main(argc argv)
QApplication app(argc,argv)
QWidget widget;
QLabel *mylable = new QLable(" Hello world ");
QVBoxLayout *layout = new QVBoxLaout;
return app.exec();

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
geoffryfAuthor Commented:
This is perfect. I need both Qt Creator method and code method.

Your sample code helped me to resolve my concerns.

Thanks :)
I am glad I was able to help. I wonder why this question was asked in c++ zone, Qt zone is there under IDE
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.