Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. QWidget touch event

QWidget touch event

Scheduled Pinned Locked Moved Unsolved Language Bindings
2 Posts 2 Posters 1.6k 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.
  • A Offline
    A Offline
    alekssandrap
    wrote on last edited by
    #1

    Hi, I am developing GUI app using QtDesigner and PyQt4. I have touch display, and want to implement pinch-zoom method. But i have problem with touch events. I am running simple code with event handler , I am entering the function (I tested it with print statement right before if statement) but QEvents are not detected. Please any suggestions, what am I doing wrong?
    P.S Mouse events are working, I have problem with touch events.
    import sys
    import math

    from PyQt4.QtCore import *
    from PyQt4.QtGui import *
    from PyQt4.uic import *
    from types import *

    def handleEvent(self, event):
    if event.type() in [QEvent.TouchBegin, QEvent.TouchUpdate, QEvent.TouchEnd]:
    print ("Touch event")
    print (event.type())
    tp = event.toichPoints()
    for p in tp:
    print(p.pos())

    return True

    app = QApplication(sys.argv)
    w = loadUi("main.ui")

    w.widget.setAttribute(Qt.WA_AcceptTouchEvents)

    w.widget.event = MethodType(handleEvent, w.widget)

    w.show()
    sys.exit(app.exec_())

    1 Reply Last reply
    0
    • the_T Offline
      the_T Offline
      the_
      wrote on last edited by
      #2

      What does " i have problem with touch events" mean in your case?

      ps: And please use code tags when posting code

      import  foo from bar
      
      def foobar():
        print("this is more readable")
      

      is much easier to read than

      import foo from bar

      def foobar():
      print("this is not readable")

      ;)

      -- No support in PM --

      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