[Qt-interest] How to get mouse cursor position from QEvent

Steven Chang steven01 at ms3.hinet.net
Mon Feb 22 18:38:29 CET 2010


Hi Ulf,

Since the enterEvent() function only accepts QEvent, but cannot accept
QMouseEvent.
void QWidget::enterEvent ( QEvent * event )
So I can only try to get mouse position from QEvent.
I tried to use QMouseEvent instead of QEvent in enterEvent(), and it could
pass compiler, but the function never be called in run time.

Best Regards,
Steven

-----Original Message-----
From: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] On Behalf Of Ulf-Alexander v.
Ceumern-Lindenstjerna
Sent: Tuesday, February 23, 2010 12:55 AM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] How to get mouse cursor position from QEvent

Hi.

I was just about to suggest casting the event to a QMouseEvent, when I
saw that QWidget::enterEvent ( QEvent * event ) receives a plain
"QEvent". Kind of strange, since this is an event triggered by mouse
interaction. Is there a reason for it that I can't see?

/Ulf

> -----Original Message-----
> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-
> bounces at trolltech.com] On Behalf Of Steven Chang
> Sent: Monday, February 22, 2010 5:23 PM
> To: qt-interest at trolltech.com
> Subject: [Qt-interest] How to get mouse cursor position from QEvent
> 
> Dear Sir,
> 
> 
> 
> I re-implement Qt QWidget's protected function "void enterEvent(QEvent
> *event);".
> 
> How can I get the enter point or mouse cursor position from the
> parameter(*event) of enterEvent function?
> 
> Thanks a lot!
> 
> 
> 
> Best Regards,
> 
> Steven


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




More information about the Qt-interest-old mailing list