[Interest] QPointF in QMouseEvent

Thiago Macieira thiago.macieira at intel.com
Mon Sep 21 06:54:31 CEST 2015


On Monday 21 September 2015 01:50:44 Brad Pepers wrote:
> I was wondering if anyone knows why QMouseEvent::pos() returns a QPoint but
> QMouseEvent::localPos() returns a QPointF.  When do you ever have
> fractional pixels?  When would pos() and localPos() be different?

A simple look at the header would have answered:

    inline QPoint pos() const { return l.toPoint(); }

    const QPointF &localPos() const { return l; }

The two coordinates are the same.

Qt uses floating point coordinates for compatibility with graphics view and for 
future compatibility.
-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Interest mailing list