Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, October 2007
QMouseEvent position on scrolling


Message 1 in thread

Hi,
 
I have a QGraphicsView with a scrollbar (scene is of bigger size than
view widget) and I am handling its mouse press events.
The location event->pos() does not consider scrolling and I do not get
the correct scene position, if I scroll the view.
The scene is anchored at the Topleft position of the view widget.
 
I currently add the scrolled offset the event->pos() to get actual scene
position.
It works but seems like a dirty hack and I am not sure if it will work
in all cases.
 
Any ideas on how to resolve this issue ?
 
R's
Prateek

Message 2 in thread

On 22/10/2007, at 12.02, Prateek Tiwari wrote:
> I have a QGraphicsView with a scrollbar (scene is of bigger size  
> than view widget) and I am handling its mouse press events.
> The location event->pos() does not consider scrolling and I do not  
> get the correct scene position, if I scroll the view.
> The scene is anchored at the Topleft position of the view widget.
>
> I currently add the scrolled offset the event->pos() to get actual  
> scene position.
> It works but seems like a dirty hack and I am not sure if it will  
> work in all cases.

Have you tried using mapToScene(event->pos()) ?

Frederik

-- 
 [ signature omitted ] 

Message 3 in thread

Yes. But that doesnt work either :( 

-----Original Message-----
From: Frederik Juul Christiani [mailto:juul@xxxxxxxxxxxxxxxxxxxxx] 
Sent: Monday, October 22, 2007 5:38 PM
To: qt-interest@xxxxxxxxxxxxx
Subject: Re: QMouseEvent position on scrolling


On 22/10/2007, at 12.02, Prateek Tiwari wrote:
> I have a QGraphicsView with a scrollbar (scene is of bigger size than 
> view widget) and I am handling its mouse press events.
> The location event->pos() does not consider scrolling and I do not get

> the correct scene position, if I scroll the view.
> The scene is anchored at the Topleft position of the view widget.
>
> I currently add the scrolled offset the event->pos() to get actual 
> scene position.
> It works but seems like a dirty hack and I am not sure if it will work

> in all cases.

Have you tried using mapToScene(event->pos()) ?

Frederik

--
 [ signature omitted ]