Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QGraphicsView scrolls unexpectedly after a QTouchEvent
Qt 6.12 LTS is out! See what's new in the release blog

QGraphicsView scrolls unexpectedly after a QTouchEvent

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
6 Posts 3 Posters 2.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Grynium
    wrote on last edited by
    #1

    I'm implementing an image viewer on an embedded platform. The hardware is a sort of tablet and has a touch screen as input device. The Qt version I'm using is 5.4.3.

    The QGraphicsView is used to display a QGraphicsScene which contains a QGraphicsPixmapItem. The QGraphicsPixmapItem containts the pixmap to display.

    The relevant part of the code is the following:

    void MyGraphicsView::pinchTriggered(QPinchGesture *gesture)
    {
    QPinchGesture::ChangeFlags changeFlags = gesture->changeFlags();
    
    if (changeFlags & QPinchGesture::ScaleFactorChanged) {
        currentStepScaleFactor = gesture->totalScaleFactor();
    }
    
    if (gesture->state() == Qt::GestureFinished) {
        scaleFactor *= currentStepScaleFactor;
        currentStepScaleFactor = 1;
        return;
    }
    
    // Compute the scale factor based on the current pinch level
    qreal sxy = scaleFactor * currentStepScaleFactor;
    
    // Get the pointer to the currently displayed picture
    QList<QGraphicsItem *> listOfItems = items();
    QGraphicsItem* item = listOfItems.at(0);
    
    // Scale the picture
    item.setScale(sxy);
    
    // Adapt the scene to the scaled picture
    setSceneRect(scene()->itemsBoundingRect());
    }
    

    After the pinch a touch on the screen causes a strange behaviour. The view scrolls unexpectedly causing a bad glitch.

    Below the events that are dispatched to the scene during the pinch action and subsequent touch:

    // Pinch action
    MyGraphicsScene::event - Event  8 , accepted
    MyGraphicsScene::event - Event  194 , accepted
    MyGraphicsScene::event - Event  10 , not accepted
    MyGraphicsScene::event - Event  156 , accepted
    MyGraphicsScene::event - Event  195 , accepted
    MyGraphicsScene::event - Event  195 , accepted
    MyGraphicsScene::event - Event  43 , accepted
    MyGraphicsScene::event - Event  195 , accepted
    MyGraphicsScene::event - Event  43 , accepted
    MyGraphicsScene::event - Event  195 , accepted
    MyGraphicsScene::event - Event  43 , accepted
    MyGraphicsScene::event - Event  195 , accepted
    MyGraphicsScene::event - Event  195 , accepted
    MyGraphicsScene::event - Event  195 , accepted
    MyGraphicsScene::event - Event  195 , accepted
    MyGraphicsScene::event - Event  43 , accepted
    MyGraphicsScene::event - Event  195 , accepted
    MyGraphicsScene::event - Event  195 , accepted
    MyGraphicsScene::event - Event  195 , accepted
    MyGraphicsScene::event - Event  195 , accepted
    MyGraphicsScene::event - Event  43 , accepted
    MyGraphicsScene::event - Event  195 , accepted
    MyGraphicsScene::event - Event  43 , accepted
    MyGraphicsScene::event - Event  195 , accepted
    MyGraphicsScene::event - Event  195 , accepted
    MyGraphicsScene::event - Event  43 , accepted
    MyGraphicsScene::event - Event  195 , accepted
    MyGraphicsScene::event - Event  43 , accepted
    MyGraphicsScene::event - Event  198 , accepted
    MyGraphicsScene::event - Event  195 , accepted
    MyGraphicsScene::event - Event  198 , accepted
    MyGraphicsScene::event - Event  195 , accepted
    MyGraphicsScene::event - Event  195 , accepted
    MyGraphicsScene::event - Event  198 , accepted
    MyGraphicsScene::event - Event  196 , accepted
    MyGraphicsScene::event - Event  43 , accepted
    
    // Touch action which causes the problem
    MyGraphicsScene::event - Event  194 , accepted
    MyGraphicsScene::event - Event  195 , accepted
    MyGraphicsScene::event - Event  196 , accepted
    MyGraphicsScene::event - Event  157 , accepted
    

    where:

    TouchBegin = 194,
    TouchUpdate = 195,
    TouchEnd = 196,
    GraphicsSceneMousePress = 156,
    GraphicsSceneMouseRelease = 157,
    

    It seems that when the glitch appears the GraphicsSceneMousePress event (=156) is not dispatched to the scene.

    Which is the cause of the problem? Is it a bug of the QGraphicsView/QGraphicsScene/QGraphicsPixmap objects? How to fix the problem?

    Thanks in advance

    Best regards

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Before going on a bug hunt, you should try with a more recent version of Qt the current it 5.5.1 with 5.6.0 in beta.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      G 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Before going on a bug hunt, you should try with a more recent version of Qt the current it 5.5.1 with 5.6.0 in beta.

        G Offline
        G Offline
        Grynium
        wrote on last edited by
        #3

        @SGaist I'm sorry but the Qt version in use is freezed and I can not switch

        1 Reply Last reply
        0
        • G Offline
          G Offline
          Grynium
          wrote on last edited by
          #4

          I've made further investigations debugging the touch controller in use.

          The sequence of touches which causes the problem is:

          • touch with the thumb
          • touch at the same time with the forefinger (gesture started)
          • remove the thumb
          • remove the forefinger (gesture ended)

          At this point if I execute a new touch on the screen the glitch appears.

          The glitch is NOT present if using the subsequent sequence:

          • touch with the thumb
          • touch at the same time with the forefinger (gesture started)
          • remove the forefinger
          • remove the thumb (gesture ended)

          Below a log of my touch controller related to the two sequences.

          Sequence which causes the problem:
          // Touch with the thumb
          Event: time 1451525078.959483, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value 2023
          Event: time 1451525078.959483, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 13264
          Event: time 1451525078.959483, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 7824
          Event: time 1451525078.959483, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1
          Event: time 1451525078.959483, type 3 (EV_ABS), code 0 (ABS_X), value 13264
          Event: time 1451525078.959483, type 3 (EV_ABS), code 1 (ABS_Y), value 7824
          Event: time 1451525078.959483, -------------- SYN_REPORT ------------

          // Touch at the same time with the forefinger (gesture started)
          Event: time 1451525081.378908, type 3 (EV_ABS), code 47 (ABS_MT_SLOT), value 1
          Event: time 1451525081.378908, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value 2024
          Event: time 1451525081.378908, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 18016
          Event: time 1451525081.378908, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 15392
          Event: time 1451525081.378908, -------------- SYN_REPORT ------------

          // Remove the thumb
          Event: time 1451525083.165372, type 3 (EV_ABS), code 47 (ABS_MT_SLOT), value 0
          Event: time 1451525083.165372, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 13280
          Event: time 1451525083.165372, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 7840
          Event: time 1451525083.165372, type 3 (EV_ABS), code 0 (ABS_X), value 13280
          Event: time 1451525083.165372, type 3 (EV_ABS), code 1 (ABS_Y), value 7840
          Event: time 1451525083.165372, -------------- SYN_REPORT ------------
          Event: time 1451525083.167019, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value -1
          Event: time 1451525083.167019, type 3 (EV_ABS), code 0 (ABS_X), value 18016
          Event: time 1451525083.167019, type 3 (EV_ABS), code 1 (ABS_Y), value 15392
          Event: time 1451525083.167019, -------------- SYN_REPORT ------------

          // Remove the forefinger (gesture ended)
          Event: time 1451525084.879579, type 3 (EV_ABS), code 47 (ABS_MT_SLOT), value 1
          Event: time 1451525084.879579, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 15456
          Event: time 1451525084.879579, type 3 (EV_ABS), code 1 (ABS_Y), value 15456
          Event: time 1451525084.879579, -------------- SYN_REPORT ------------
          Event: time 1451525084.881247, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value -1
          Event: time 1451525084.881247, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 0
          Event: time 1451525084.881247, -------------- SYN_REPORT ------------

          // New touch which causes the glitch
          Event: time 1451525443.035846, type 3 (EV_ABS), code 47 (ABS_MT_SLOT), value 0
          Event: time 1451525443.035846, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value 2027
          Event: time 1451525443.035846, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 11088
          Event: time 1451525443.035846, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 10816
          Event: time 1451525443.035846, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1
          Event: time 1451525443.035846, type 3 (EV_ABS), code 0 (ABS_X), value 11088
          Event: time 1451525443.035846, type 3 (EV_ABS), code 1 (ABS_Y), value 10816
          Event: time 1451525443.035846, -------------- SYN_REPORT ------------
          Event: time 1451525443.927823, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 10832
          Event: time 1451525443.927823, type 3 (EV_ABS), code 1 (ABS_Y), value 10832
          Event: time 1451525443.927823, -------------- SYN_REPORT ------------
          Event: time 1451525443.929448, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value -1
          Event: time 1451525443.929448, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 0
          Event: time 1451525443.929448, -------------- SYN_REPORT ------------

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            While I understand the version freeze, you should anyway take a look at the state with a more recent version. That way if the bug disappeared you know you can check Qt's sources to find what was changed and maybe rebuild Qt with the patches in place.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • D Offline
              D Offline
              drjakir 0
              wrote on last edited by
              #6

              For anyone stumbling upon this thread (as I did) while experiencing strange pinch/mouse behaviour as described.

              It is still an unresolved problem in Qt 5.9.5 at least, and seems to have been resolved in 5.11 beta 4 (or somewhere in between).

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt
              • Unsolved