This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Resize QFrame's inner widgets [SOLVED]

Tags: None
(comma "," separated)
Musikolo
Registered Member
Posts
27
Karma
0
OS
Hi,

I'm writing an application having a QFrame object which has the following widget structure inside:
1.- QHBoxLayout
1.1.- QVBoxLayout
1.1.1.-QHBoxLayout
1.1.1.1.- QLabel
1.1.1.2.- QLabel
1.1.1.3.- QLabel
1.1.2.-QHBoxLayout
1.1.2.1.- QLabel
1.1.3.-QHBoxLayout
1.1.3.1.- QLabel
1.1.3.2.- QUrlLabel
1.2.- QLabel

The QFrame has the [Expanding, Fixed] sizePolicy, so it expands only horizontally and it does fine as expected. However, inner objects described in the above structure remain still and do not move as the QFrame resizes.

Just doing some tests, I have moved the whole structure out of the QFrame and it moves as the MainWindow resizes, but when I put back it inside the QFrame it doesn't.

How could a fix this?

Best regards!

Last edited by Musikolo on Sat Jan 22, 2011 9:46 am, edited 1 time in total.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: Resize QFrame's inner widgets

Wed Jan 19, 2011 8:27 am
You probably want to look at a QGridLayout for your items, which should also simplify the code.

In any case make sure you have set a layout on the QFrame, which should be "1." from your diagram.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
Musikolo
Registered Member
Posts
27
Karma
0
OS

Re: Resize QFrame's inner widgets

Wed Jan 19, 2011 8:11 pm
@bcooksley: Thanks for your reply. :)

The problem I have, please, let me know if I'm wrong, it's that QGridLayout does not allow the same visual effects as a QFrame does. It currently has framShape=StyledPanel and frameShadow=Raised. What I'm intended to is to have a kind-of panel (QFrame) using the Raised visual effect and place all those QLabels on it. Is it possible to do the same thing with a QGridLaout or by some other way? ???

Best regards! ;-)
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: Resize QFrame's inner widgets  Topic is solved

Wed Jan 19, 2011 11:00 pm
You are getting things confused here. You would use QFrame with QGridLayout managing it's contents. Your current approach has you using a QFrame with QHBoxLayout managing it's contents.

In any case, your current code, assuming it doesn't use designer, is probably missing the needed QFrame setLayout() call.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
Musikolo
Registered Member
Posts
27
Karma
0
OS

Re: Resize QFrame's inner widgets

Sat Jan 22, 2011 9:46 am
@bcooksley: I love you man, by doing what you said fixed the issue:

Code: Select all
frame->setLayout( frameMainLayout );

Thanks a million!


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], ourcraft