PDA

View Full Version : QGraphicsView user-resizable images - for children



magland
5th October 2007, 15:42
I want to make some fun tools for my children.

Does anybody know of an extension of QGraphicsView that allows user to resize scene items (such as QGraphicsPixmapItem).... or is there an easy way to code it?

A related question, has anybody tried to created a QGraphicsView where user can insert objects (shapes, lines, images) and then manipulate them (powerpoint-style)?

Finally, any fun Qt widgets for children? I'd like to organize a collection.

momesana
5th October 2007, 16:06
I want to make some fun tools for my children.

Does anybody know of an extension of QGraphicsView that allows user to resize scene items (such as QGraphicsPixmapItem).... or is there an easy way to code it?

you can scale the item using item->scale() or resize the item by changing its boudingRect, and painting the new image with the new size inside the item. If you are working with a QPixmaps you can derive from QGraphicsItem, keep a copy of the pixmap and resize it for display using different geometries by using QPixmap::scaled().



A related question, has anybody tried to created a QGraphicsView where user can insert objects (shapes, lines, images) and then manipulate them (powerpoint-style)?

Finally, any fun Qt widgets for children? I'd like to organize a collection.
Yes. I did that and it worked pretty fine. I had used plugins that returned a QGraphicsItem. So you can later add whatever shapes you like without touching the applications code.

magland
5th October 2007, 16:21
you can scale the item using item->scale() or resize the item by changing its boudingRect, and painting the new image with the new size inside the item. If you are working with a QPixmaps you can derive from QGraphicsItem, keep a copy of the pixmap and resize it for display using different geometries by using QPixmap::scaled().


But to me the difficult part would be implementing the user-drag resizing part...... I know, not too hard, but just wondering if somebody has already taken care of this.



Yes. I did that and it worked pretty fine. I had used plugins that returned a QGraphicsItem. So you can later add whatever shapes you like without touching the applications code.

Sounds very useful. Would you be willing to share your code with me?