[Qt-jambi-interest] Polygonzug
Gunnar Sletta
gunnar at trolltech.com
Thu May 8 10:10:04 CEST 2008
Dawid Sip wrote:
> Hi,
> I'm working on an option in my graphics editing application for drawing
> Polygon around an object in an image. It should work comparably to Path
> in Gimp except for that I'd like the line between the last added vertex
> and the one to be placed to be animated (stretched between the pouse
> pointer and the last added vertex. I cant really find any example in
> which i could look up howto do this so I'm hoping someone could point me
> in the right direction. I forgot to mention.
Hi Dawid,
I assume you want to do this on a QGraphicsView, since this is what you
were using in the previous post. I've attached a small example that
shows how this can be done.
Basically you maintain two shapes. The first is what you have built so
far, in my case a plain QPainterPath. The second is a line. The last
point on the QPainterPath corresponds to the first point in the line and
when you move the mouse you update the last point in the line, thus
animating it along the cursor.
If you want to do this on a plain widget it will be almost identical,
except you need to implement a paintEvent and draw the actual path and line.
> I'm using an small
> rectangle made in .svg for vertices. This is because i need the polygon
> to be scalable when i zoom in or out..
QPainter and QGraphicsView are vectorial and will zoom for you. Unless
you want an especially fancy looking rectangle, just setting a zoom
factor on the graphics view or painter and drawing the rect will do.
best regards,
Gunnar
-------------- next part --------------
A non-text attachment was scrubbed...
Name: GraphicsShapeThingy.java
Type: text/java
Size: 1600 bytes
Desc: not available
Url : http://lists.trolltech.com/pipermail/qt-jambi-interest/attachments/20080508/e6d65459/attachment-0001.bin
More information about the Qt-jambi-interest
mailing list