[Qt-interest] Advice on QGraphicsScene, View, ...

Christian Gagneraud cgagneraud at techworks.ie
Mon Jul 12 18:48:24 CEST 2010


On 07/12/2010 01:18 PM, Martin Hofius wrote:
> Hi Christian,
>
> Am Montag, 12. Juli 2010 schrieb Christian Gagneraud:
>> Hi all,
>>
>> I'm currently working on a kind of diagram editor. For now I'm
>> focusing only on the basics: background, grid and zoom.
>>
>> What I would like to do is to add a "mouse position marker" which will
>> snap on the grid, typically it should be made of one vertical line,
>> spreading all the height of the display area and one horizontal line
>> that spread all the width of the display area. But I don't want to
>> replace the mouse cursor, which will still be used to reflect the
>> current operating mode (selection, move, ...).
> ...
>> 2 - The position marker moves only when the mouse move *and* a mouse
>> button is pressed. What I would like to do is make the marker follow
>> the mouse pointer, all the time, but I didn't find any MouseHover event.
>
> maybe You are looking for:
>
> void QWidget::grabMouse ()
>
> and
>
> void QWidget::releaseMouse ()
>
> to get all mouse movement events. But be careful: You can block Your whole
> screen with this function...

Hi Matin,

Thanks for the answer.
This solution looked pretty low-level and puzzled me. After having 
read the documentation and googling a bit more, I found that:
http://doc.qt.nokia.com/4.6/qwidget.html#mouseTracking-prop

With this enabled, mouseMoveEvent() get called each time the mouse 
move, exactly what I wanted!

Thanks,
Chris





>
> Greetings
> Martin
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest


-- 
Christian Gagneraud,
Electronics and software engineer

TechWorks Marine Ltd
4a, Park Lane
Dun Laoghaire, Co Dublin
Ireland

Tel: + 353 1 2365990
Fax: + 353 1 2365992
Web: www.techworks.ie





More information about the Qt-interest-old mailing list