You are not logged in.

#1 2009-12-09 13:53:53

Tyriel
Member
From: Melbourne, Australia
Registered: 2009-01-20
Posts: 161
Website

Small issue with Qt

I am trying to learn Qt by making a simple application.  However when I resize the parent (main) window, I would like for the frames inside to expand or shrink to the same dimensions. 

Does anyone know if there is a simple way to accomplish this?


The software required Windows XP or better, so I installed archlinux.

Offline

#2 2009-12-09 14:05:30

Wittfella
Member
From: Australia
Registered: 2008-05-27
Posts: 462

Re: Small issue with Qt

Play with a form in Designer first and experiment with the layout options so you can get a feel for what they do and all the options that are available.

If you are manually coding check out QVBoxLayout and QHBoxLayout in the documentation, that should get you going.  Nested layouts can be quite confusing when trying to do them manually in code though, thats why it help heaps if you play around in Designer first.

Offline

#3 2009-12-09 14:15:53

Tyriel
Member
From: Melbourne, Australia
Registered: 2009-01-20
Posts: 161
Website

Re: Small issue with Qt

Thanks for the prompt reply, I was trying to code it manually but I will take your advice and try a UI designer for now until I understand it a little more.   Will start reading the QVBoxLayout and QHBoxLayout documentation now.


The software required Windows XP or better, so I installed archlinux.

Offline

#4 2009-12-09 17:34:32

scio
Member
From: Buffalo, NY
Registered: 2008-08-05
Posts: 366

Re: Small issue with Qt

Offline

#5 2009-12-10 07:13:25

HashBox
Member
Registered: 2009-01-22
Posts: 271

Re: Small issue with Qt

I've just recently started using QT, basically what you want to do is something like this (inside your main window constructor):

// Create a layout
QVBoxLayout *layout = new QVBoxLayout(this);
this->setLayout(layout);

// Then after you create your frame
layout->addWidget(frame);

The layout should take care of any resizing events smile

Offline

#6 2009-12-10 10:27:36

Tyriel
Member
From: Melbourne, Australia
Registered: 2009-01-20
Posts: 161
Website

Re: Small issue with Qt

Thank you for all the suggestions and examples as I got it working today.  I still have much to learn but this was a good start.


The software required Windows XP or better, so I installed archlinux.

Offline

#7 2009-12-21 20:05:11

zolookas
Member
Registered: 2005-06-03
Posts: 44

Re: Small issue with Qt

If you are using Qt Designer, add some widgets, right click on empty space in your window select "lay out" and choose how to lay out them. You can also insert layouts inside layouts if you need.

For example: drag three buttons on your window in Qt Designer, choose "lay out" and "lay out vertically" and magic happens smile Now, drop horizontal layout on your window and try to place few buttons in it. Then you should have an understanding how layouts work smile

Last edited by zolookas (2009-12-21 20:06:27)

Offline

Board footer

Powered by FluxBB