QWidget touch event



  • 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_())



  • 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")

    ;)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.