[Qt-interest] A (newbie?) question using QGraphicsLinearLayout
Mihail Naydenov
mlists at ymail.com
Wed Apr 14 11:42:33 CEST 2010
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
More information about the Qt-interest-old
mailing list