I need to check if a mouse button is clicked or released. I'm using pyqt - any way to check the mouse button release state in qt or directly in python?
I know of pygame module but would prefer not to have to install it.
Check you doc at PyQt4/doc/html/qt.html#MouseButton-enum
Constant Value
Qt.NoButton 0x00000000
Qt.LeftButton 0x00000001
Qt.RightButton 0x00000002
Qt.MidButton 0x00000004
Qt.MiddleButton MidButton
Qt.XButton1 0x00000008
Qt.XButton2 0x00000010
A simple example:
>>> from PyQt4 import QtCore, QtGui
>>> app=QtGui.QApplication([])
>>> mouse_state=app.mouseButtons()
>>> mouse_state==QtCore.Qt.NoButton
True
>>> int(mouse_state)
0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With