[PyQt] Can't call QTest::touchEvent(&widget)
Anton Chikin
kverlin.lists at gmail.com
Thu Apr 14 10:57:09 BST 2011
On Wed, Apr 13, 2011 at 9:09 PM, Phil Thompson
<phil at riverbankcomputing.com> wrote:
> On Wed, 13 Apr 2011 14:31:05 +0400, Anton Chikin <kverlin.lists at gmail.com>
> wrote:
>> Hello All,
>>
>> I'm using PyQt version 4.8.3-2, shipped with Ubuntu 11.04 beta. While
>> I was trying to use new multitouch testing function
>> QTest::touchEvent() http://doc.qt.nokia.com/4.7/qtest.html#touchEvent
>> I've come across the issue. This piece of code
>>
>> from PyQt4 import QtTest
>> def testMT(self):
>> QtTest.QTest.touchEvent(self).press(0, QPoint(100,100))
>>
>> causes
>>
>> AttributeError: type object 'QTest' has no attribute 'touchEvent'
>>
>> I discovered that this function is not listed in PyQt4 docs.
>> http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qtest.html
>>
>> Could you please give me some guidelines to resolve this?
>> Thank you!
>> Anton Chikin.
>
> Hmm - not sure how it got missed. It will be in tonight's snapshot.
>
> Thanks,
> Phil
>
Hi Phil,
I've come across another issue using multitouch test functions.
Please have a look at QTouchEventSequence doc page
http://doc.qt.nokia.com/4.7-snapshot/qtest-qtoucheventsequence.html
I wrote the following sample to demonstrate the issue:
-------------------------------------------------------------------------------------
import sys
import inspect
from PyQt4 import QtCore, QtGui, QtTest
class MyLabel(QtGui.QLabel):
def __init__(self, string, parent = None):
QtGui.QLabel.__init__(self, string, parent)
self.resize(500,300)
def event(self, evt):
if evt.type() == QtCore.QEvent.TouchBegin:
print("TouchBegin!")
#Double click causes QTouchEvent to be sent
if evt.type() == QtCore.QEvent.MouseButtonDblClick:
print("Double click!")
self.testMT()
return QtGui.QLabel.event(self, evt)
def testMT(self):
evSeq = QtTest.QTest.touchEvent(self)
print(inspect.getmembers(evSeq))
evSeq.press(0, QtCore.QPoint(10,10), self) #<------- Python
crashes here!
print("MT event sent!")
return
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
label = MyLabel("Hello!")
label.show()
app.exec_()
sys.exit()
--------------------------------------------------------------------------------------
At the line, where I try to call QTouchEventSequence.press() - Python
crashes with core dump.
Is this the real issue or just I am doing wrong things?
Thank you,
Anton Chikin
More information about the PyQt
mailing list