[Qt-interest] translate path's coordinates

Ioannis Nousias s0238762 at sms.ed.ac.uk
Mon Jun 8 21:43:55 CEST 2009


This ended up being a monologue...

this is for the benefit of anyone new to Qt, such as myself, that might 
be trying to do something similar. Feel free to comment.

to answer my own question, yes there is a better way, by using the 
Graphics View Framework.

I've attached my little demo here.

regards,
Ioannis





Ioannis Nousias wrote:
> actually, sorry, it's not deformed, rather 'cliped'. I realised it's due 
> to the boundingRect(), which I pass to the update() method, not being 
> 'translated' as well.
>
> now that the matrix has changed for that path, I need to manually 
> 'translate' the mouse pointer (I store a QMatrix per path and do 
> matrix.inverted.map(mouse_point) to get the 'translated' pointer) in 
> order for the highlight detection to work on that path, all of which 
> looks hacky to me.
>
> there must be a cleaner way to do this whole thing...
>
> Ioannis Nousias wrote:
>   
>> Hello qt-devs
>>
>> Is there a way to change where a path is drawn? I've tried setting the 
>> world matrix on the painter, but that did something I was not expecting. 
>> The path got deformed.
>>
>> Basically, I have a little drawing tool. You draw shapes/paths with your 
>> mouse. Each time you press the mouse button it starts a new path and 
>> continues 'adding' to that path until you release the button. The paths 
>> are stored in a list.
>>
>> When you hover over a path (the cursor is atop its contour), the shape 
>> is highlighted and you are suppose to be able to move it around. I use 
>> QPainterPathStroker and contains() to detect if the mouse is over a path.
>>
>> Any ideas? Is there some other neater way to do this whole thing (maybe 
>> using QGraphicsView and QGraphicsItem's or something. At the moment I 
>> just draw things on a QWidget)
>>
>> regards,
>> Ioannis
>>
>>
>>   
>>     
>
>
>   


-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: gfxview.cpp
Type: text/x-c++src
Size: 3951 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090608/2cbd93f2/attachment.bin 


More information about the Qt-interest-old mailing list