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


Messages In This Thread
PyQt4 Touch events - by alekssandrap - Jan-27-2017, 02:33 PM
RE: PyQt4 Touch events - by Larz60+ - Jan-27-2017, 04:41 PM
RE: PyQt4 Touch events - by alekssandrap - Jan-28-2017, 01:05 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Looking for good GUI Framework for Touch Devices matt_the_hall 2 2,220 Feb-02-2021, 03:36 AM
Last Post: matt_the_hall
  [PyQt] Wonky Touch Events hessej 2 2,346 Nov-07-2019, 07:52 PM
Last Post: kozaizsvemira
  [PyQt] PyQt4 dynamic QComboBox littleGreenDude 4 5,734 Jan-02-2019, 07:22 PM
Last Post: littleGreenDude
  [PyQt] PyQt4 handle dynamic checkbox click littleGreenDude 1 6,620 Dec-27-2018, 09:17 PM
Last Post: littleGreenDude
  PyQt4 installation frustration littleGreenDude 4 4,581 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,299 Sep-18-2018, 01:21 PM
Last Post: Alfalfa
  How to Integrate PyQt4 Custom Widget with Qt Designer Zukias 1 3,942 Aug-29-2018, 05:33 PM
Last Post: Zukias
  Updating Python version from command prompt and Conversion from PyQt4 to PyQt5 Vysero 4 4,991 Jul-19-2018, 03:15 PM
Last Post: Vysero
  Trouble displaying an image in PyQt4 Vysero 2 3,135 Jul-01-2018, 05:25 PM
Last Post: Alfalfa
  [PyQt] touch events is not generating shridhara 0 3,423 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