I implemented an image browser where I use the wheel event of the mouse to show the next image. The problem is, if the user scrolls too fast, the position value of the scroll wheel jumps over and swallows the values in between. Does anybody know how I can overcome this problem? If I scroll slowly, I get a decreasing value (-1, -2, -3); if I scroll fast I get something like (-1, -5, -6, -11). The problem appears on WindowsXP & 7.
Here is a sample code.
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys
#############Define MyWindow Class Here ############
class MyWindow(QMainWindow):
##-----------------------------------------
def __init__(self):
QMainWindow.__init__(self)
self.label = QLabel("No data")
self.label.setGeometry(100, 200, 100, 100)
self.setCentralWidget(self.label)
self.setWindowTitle("QMainWindow WheelEvent")
self.x = 0
##-----------------------------------------
def wheelEvent(self,event):
self.x =self.x + event.delta()/120
print self.x
self.label.setText("Total Steps: "+QString.number(self.x))
##-----------------------------------------
##########End of Class Definition ##################
def main():
app = QApplication(sys.argv)
window = MyWindow()
window.show()
return app.exec_()
if __name__ == '__main__':
main()
event.delta()
remain constant? My mouse wheel is "clicky", and the delta is a constant ±120 units. – Pardew