PDA

View Full Version : QGraphicsWidget Position Promble



weihao.ma
25th February 2011, 10:49
Hi, everyone,

I want to implement a custom QGraphicsLayout that works in the following manner.The item added to the custom layout can be position absolutely by call setpos() function. I don't want to use QGraphicsAnchorLayout, QGraphicsGridLayout, and QGraphicsLinearLayout, because when the item was added to the common layout, setpos() function not work.

Or Is there method after the item was added to the common layout , i still can move the item's anywhere within the parent coordinate?

...
QGraphicsLinearLayout *layout = new QGraphicsLinearLayout;
layout->setContentsMargins(25,25,25,25);
layout->setMinimumSize(603,368);

layout->addItem(proxyForName["helpBtn"]);
proxyForName["helpBtn"]->setPos(100,100); -> not work
setLayout(layout);
...

wysota
27th February 2011, 09:40
If the item is in a layout then you can't change its position because it would break the layout.

weihao.ma
28th February 2011, 17:43
Is any other way i can work around? I want to put a QGraphicsWidget into the other QGraphicsWidget, the fronter widget locate above the later, so i want to know is any method position the fronter one absolutly within the later widget's coordinate, other than binding to layout.

wysota
28th February 2011, 20:51
Is any other way i can work around?
You can just not use layouts.

weihao.ma
4th March 2011, 06:53
If i just not use layout, how can i put QGraphicsWidget into another QGraphicsWidget, QGraphicsWidget doesn't supports the api, but addLayout() api is available.

MarekR22
4th March 2011, 09:18
give a parent during construction or use QGraphicsItem::setParentItem.