Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Why does QScrollArea scroll on multi-touch even if nobody told it to?

Why does QScrollArea scroll on multi-touch even if nobody told it to?

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 252 Views
  • 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.
  • N Offline
    N Offline
    nobru
    wrote on last edited by
    #1

    I'm using a multi-touch monitor (EIZO DuraVision FDF2382WT) with Lubuntu 18.04. I have a QScrollArea with a QLabel as widget. The QLabel has a QPixmap. Touching it with two or more fingers scrolls the picture. Why does this happen? According to my understanding of the documentation QTouchEvent handling is opt-in, except for QWindows which always receive them.

    I've tried setting AA_SynthesizeMouseForUnhandledTouchEvents to False, setting WA_AcceptTouchEvents for the QScrollArea and QLabel to both True and False. I saw no changes. I've tried reimplementing QScrollArea.event, QScrollArea.scroll, QLabel.event and the scroll bar setValue to log the calls, but nothing is printed.

    import sys
    
    from PyQt5 import Qt
    
    qapp = Qt.QApplication(sys.argv)
    
    picture = Qt.QPixmap('picture.png')
    
    qlab = Qt.QLabel()
    qlab.setPixmap(picture)
    
    qsa = Qt.QScrollArea()
    qsa.setWidget(qlab)
    qsa.setGeometry(10, 30, 200, 200)
    qsa.show()
    
    sys.exit(qapp.exec_())
    

    I was expecting the picture to stay in place, instead it is dragged. Nothing happens when dragging with the mouse or with just one finger.

    1 Reply Last reply
    0
    • N Offline
      N Offline
      nobru
      wrote on last edited by
      #2

      Finally I've solved this: it was gestures!
      I brutally disabled them with something like

      import sys
      
      from PyQt5 import Qt
      
      qapp = Qt.QApplication(sys.argv)
      
      picture = Qt.QPixmap('/home/bruno/Pictures/ABCDEFGH_red_on_green.png')
      
      qlab = Qt.QLabel()
      qlab.setPixmap(picture)
      
      MyScrollArea = Qt.QScrollArea
      
      def event(self, event):
          print('DEBUG: event type {}'.format(event.type()))
          if event.type() in (Qt.QEvent.Gesture, Qt.QEvent.GestureOverride):
              event.accept()
              return True
          else:
              return super(MyScrollArea, self).event(event)
      
      MyScrollArea.event = event
      
      qsa = MyScrollArea()
      qsa.setWidget(qlab)
      qsa.setGeometry(10, 30, 200, 200)
      qsa.show()
      
      sys.exit(qapp.exec_())
      
      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 Extensions
      • Unsolved