Results 1 to 2 of 2

Thread: QPinchGesture positions are not defined in the widget coordinate system

  1. #1
    Join Date
    Jun 2019
    Location
    France, Pau
    Posts
    39
    Thanks
    23
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default QPinchGesture positions are not defined in the widget coordinate system

    Hello everybody,

    First of all, I noticed that unlike Windows, under GNU/Linux, pinch gestures are not translated to mouse's wheel up/down events, so if I want to use zoom on a Qwt plot for example, I need to handle QGesture events in a Qt program.

    I want to use the pinch gesture on a Qwt plot canavs so I can zoom (magnify) around a particular point on the plot. I have the code working with a mouse and I just need to modify it a little bit to make it work with the multitouch (under Ubuntu).

    So I installed an event filter on the QwtPlot's canvas object to grab QGesture events and eventually called grabGesture(Qt::PinchGesture - solely on the canvas widget).

    I noticed the following things :
    QPinchGesture's startCenterPoint is always 0,0 whatever the pinch position.
    QPinchGesture's centerPoint and lastCenterPoint are not defined in the widget coordinate system, for example when I start a pinch gesture on the left-top corner of the widget, they don't return a point close to 0,0, in fact they will return something like 583, 157. for the bottom right corner, I have something like 1298,603.

    Is it a Qt bug ? I checked that mouse events (QMouseEvent:os) are in the widget coordinate system !

    I think I can translate the position to bypass this problem (QWidget::mapTo/mapFrom) but I need to find the widget defining gestures coordinate system... (main window ?)

    UPDATE: Apparently, the positions returned by QPinchGesture::centerPoint/lastCenterPoint are relative to the screen coordinate system... I will try QWidget::mapFromGlobal...
    Last edited by embeddedmz; 2nd September 2019 at 17:29.

  2. #2
    Join Date
    Jun 2019
    Location
    France, Pau
    Posts
    39
    Thanks
    23
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: QPinchGesture positions are not defined in the widget coordinate system

    In fact, the positions returned by QPinchGesture::centerPoint/lastCenterPoint are relative to the screen coordinate system and QWidget::mapFromGlobal did the trick !

Similar Threads

  1. Coordinate space vs coordinate system
    By kangaba in forum General Programming
    Replies: 0
    Last Post: 10th December 2013, 14:38
  2. QGraphicsView coordinate system
    By roband915 in forum Qt Programming
    Replies: 15
    Last Post: 5th December 2013, 06:58
  3. qt coordinate system
    By qtlearner123 in forum Newbie
    Replies: 1
    Last Post: 17th April 2012, 15:20
  4. coordinate system
    By Wojtek.wk in forum Newbie
    Replies: 7
    Last Post: 12th April 2010, 13:47
  5. The coordinate system
    By avis_phoenix in forum Qt Programming
    Replies: 1
    Last Post: 28th July 2008, 12:16

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.