Python Forum
PyQt4 Touch events
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PyQt4 Touch events
#1
Hi, I tested simple code for detecting touch event on touch-screen, but QEvent.TouchBegin, QEvent.TouchUpdate, QEvent.TouchEnd are not detected at all. Anyone help? Thank you.

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_())
[color=#000000][font=DejaVu Sans Mono]
Reply
#2
Have to assured that the handelEvent function is ever being called?
(add print statement as first item).
First thing you need to know is are events actually being triggered.
Reply
#3
Yes, I added print statement right before if statement in the handleEvent function, I was printing the event type, and I was getting results.
Also, I tested the mouse move event, that works, but the touch event is not registered. I dont know what am I missing?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Looking for good GUI Framework for Touch Devices matt_the_hall 2 2,202 Feb-02-2021, 03:36 AM
Last Post: matt_the_hall
  [PyQt] Wonky Touch Events hessej 2 2,309 Nov-07-2019, 07:52 PM
Last Post: kozaizsvemira
  [PyQt] PyQt4 dynamic QComboBox littleGreenDude 4 5,691 Jan-02-2019, 07:22 PM
Last Post: littleGreenDude
  [PyQt] PyQt4 handle dynamic checkbox click littleGreenDude 1 6,592 Dec-27-2018, 09:17 PM
Last Post: littleGreenDude
  PyQt4 installation frustration littleGreenDude 4 4,545 Dec-27-2018, 04:29 PM
Last Post: littleGreenDude
  [PyQt4] Is it right python coding scheme between TCP Server Thread and GUI class ? KimTom 3 3,261 Sep-18-2018, 01:21 PM
Last Post: Alfalfa
  How to Integrate PyQt4 Custom Widget with Qt Designer Zukias 1 3,920 Aug-29-2018, 05:33 PM
Last Post: Zukias
  Updating Python version from command prompt and Conversion from PyQt4 to PyQt5 Vysero 4 4,965 Jul-19-2018, 03:15 PM
Last Post: Vysero
  Trouble displaying an image in PyQt4 Vysero 2 3,102 Jul-01-2018, 05:25 PM
Last Post: Alfalfa
  [PyQt] touch events is not generating shridhara 0 3,386 Apr-23-2018, 11:39 AM
Last Post: shridhara

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020