PDA

View Full Version : Apply different scale on items



lni
20th February 2009, 03:28
Hi,

I have two QGraphicsWidget, one on top of the other, managed by QGraphicsGridLayout. When I do view.scale( 2, 2 ), I would like the top one ( QGraphicsWidget 1 ) to accept both x/y scale, and I want the bottom one (QGraphicsWidget 2) to accept X scale, but ignore Y scale, as shown in the chart.

How can I achieve this?

Thanks

aamer4yu
20th February 2009, 07:59
I dont think you can do that with QGraphicsView::scale function. It applies scaling to the view, not to the items.
You can however try the following -

1) Make your own function MYScale(int x, int y). In this iterate over all items. You will need to set some property in the items, or you can define the logic in this function itself. From either of 2, you can call QGraphicsItem::scale.

2) You get zoom level in graphics item. See 40000 chips demo, and you could do something similar to get ur goals

In my opinion first soln is better. Bec in your case, you want to resize items, not view. and you want to do it based on some parameters. Hence making your own function makes sense