[Qt-interest] How to get mouse cursor position from QEvent
BRM
bm_witness at yahoo.com
Mon Feb 22 19:27:32 CET 2010
But the signature for the signal/slot doesn't match.
You probably should be using the mouse related events:
Reimplement the QWidget event handlers, QWidget::mousePressEvent(), QWidget::mouseReleaseEvent(), QWidget::mouseDoubleClickEvent(), and QWidget::mouseMoveEvent() to receive mouse events in your own widgets.
QCursor::pos()
http://qt.nokia.com/doc/4.6/qmouseevent.html#details
Ben
----- Original Message ----
> From: Steven Chang <steven01 at ms3.hinet.net>
> To: Ulf-Alexander v. Ceumern-Lindenstjerna <ceumern at vrmagic.com>; qt-interest at trolltech.com
> Sent: Mon, February 22, 2010 12:38:29 PM
> Subject: Re: [Qt-interest] How to get mouse cursor position from QEvent
>
> 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
>
> _______________________________________________
> 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