[Qt-interest] A (newbie?) question using QGraphicsLinearLayout

Mihail Naydenov mlists at ymail.com
Wed Apr 14 12:55:08 CEST 2010


Thanks, I kind of figured that out (putting dummy (expanding) Items in between).
Using Stretches is The Right Way of course.

However, Im still puzzled. 

When does the alignment kick in?
Why is a single item still right aligned when the docs "By default, items are centered both vertically and horizontally."

Im still missing something

Thanks
MihailNaydenov



----- Original Message ----
> From: Ross Bencina <rossb-lists at audiomulch.com>
> To: Mihail Naydenov <mlists at ymail.com>
> Sent: Wed, April 14, 2010 1:28:27 PM
> Subject: Re: [Qt-interest] A (newbie?) question using QGraphicsLinearLayout
> 
> Hi Mihail

> I have 3 items (|_|), all with non expanding sizes. I want 
> to arrange them 
> like this:
>
> 
> |_|------------|_|------------|_|


Try 
> using:

l->addStretch();

between each 
> item.

Ross.


----- Original Message ----- 
From: "Mihail 
> Naydenov" <
> href="mailto:mlists at ymail.com">mlists at ymail.com>
To: <
> ymailto="mailto:qt-interest at trolltech.com" 
> href="mailto:qt-interest at trolltech.com">qt-interest at trolltech.com>
Sent: 
> Wednesday, April 14, 2010 7:42 PM
Subject: [Qt-interest] A (newbie?) question 
> using QGraphicsLinearLayout


> Hi,
>
> I have 3 items 
> (|_|), all with non expanding sizes. I want to arrange them 
> like 
> this:
>
> |_|------------|_|------------|_|
>
> I tried 
> QGraphicsLinearLayout :
>
>  QGraphicsLinearLayout *l = new 
> QGraphicsLinearLayout();
>
>  Item* itm = new 
> Item();
>  l->insertItem(0,itm);
>  
> l->setAlignment(itm, Qt::AlignLeft);
>
>  itm = new 
> Item();
>
>  l->insertItem(1, itm);
>  
> l->setAlignment(itm, Qt::AlignCenter);
>
>  itm = new 
> Item();
>  l->insertItem(2,itm);
>  
> l->setAlignment(itm, Qt::AlignRight);
>
> But all items are aways 
> stuck to the right :(
> |_||_||_|-----------------------
>
> 
> The closest thing I can get is if I set the second item to 
> 
> QSizePolicy::Preferred size
> ...
>  itm = new 
> Item();
>  itm->setSizePolicy(QSizePolicy::Preferred, 
> 
> sizePolicy().verticalPolicy());
>  l->insertItem(1, itm);
> 
> ...
>
> |_||________________||_|
>
>
> This, 
> however is not what I want.
>
> The docs say that if an item cannot 
> fill the space given (not expanding) 
> it will be aligned based on 
> alignments flags.
> But I fail to make it work.
> Even with one item 
> I expect it to stay in the center of the parent widget, 
> as the docs say 
> is default, but this also is not happening.
> Obviously Im missing 
> something basic.
>
> Thank You
> 
> MihailNaydenov
>
>
>
> 
> _______________________________________________
> Qt-interest mailing 
> list
> 
> href="mailto:Qt-interest at trolltech.com">Qt-interest at trolltech.com
> 
> http://lists.trolltech.com/mailman/listinfo/qt-interest 


      



More information about the Qt-interest-old mailing list