PDA

View Full Version : Drawing shapes



^NyAw^
30th October 2008, 13:41
Hi,

How can I use the mouse to draw shapes? I want to draw Rectangular, Circular, Elliptic and Irregular shapes. For Rectangular, Circular and Elliptic shapes I'd like to make them resizable by using square corners. The Irregular shape have to be painted by clicking the mouse and moving the pointer, when releasing the mouse it will have to close the shape.

I'm tinking on using QGraphicsView with every shape as QGraphicsItem but I don't know how to implement the resizing code.

Another question: I have a QScrollArea with a internal QWidget. Can the QScrollArea or the QWidget be used as viewport of the QGraphicsView?

Thanks,

jpn
30th October 2008, 20:40
How can I use the mouse to draw shapes? I want to draw Rectangular, Circular, Elliptic and Irregular shapes. For Rectangular, Circular and Elliptic shapes I'd like to make them resizable by using square corners. The Irregular shape have to be painted by clicking the mouse and moving the pointer, when releasing the mouse it will have to close the shape.

I'm tinking on using QGraphicsView with every shape as QGraphicsItem but I don't know how to implement the resizing code.
Sounds like a perfect candidate for the graphics view framework. The resizing functionality is something that needs to be written by hand.


Another question: I have a QScrollArea with a internal QWidget. Can the QScrollArea or the QWidget be used as viewport of the QGraphicsView?
Sorry, I don't follow. What would be the benefit of that? QGraphicsView is already a QAbstractScrollArea.

^NyAw^
31st October 2008, 10:19
Hi,



Sorry, I don't follow. What would be the benefit of that? QGraphicsView is already a QAbstractScrollArea.


I didn't know. ;). Just because now I'm using a QScrollArea and an internal QWidget.

Is there any example or similar code of resizing the items?

And, the Irregular shape, any idea how to do it?

Thanks,