On Tuesday 21 February 2012, 03:27:41 uahmed wrote: > hi , > > I want to do hover i saw an example and then write a script which > will be use as i made program i am facing one problem that hover only > occur if u putt mouse on the left corner of button i want that it > will happen for all the button that if i move cursor on button then > it should change. here is my code > > from PyQt4 import QtGui, QtCore > from PyQt4.QtCore import pyqtSignal > import os,sys > > class HoverButton(QtGui.QToolButton): > def enterEvent(self,event): > print("Enter") > button.setStyleSheet("background-color:#45b545;") > > def leaveEvent(self,event): > button.setStyleSheet("background-color:yellow;") > print("Leave") > app = QtGui.QApplication(sys.argv) > widget = QtGui.QWidget() > button = QtGui.QToolButton(widget) > button.setMouseTracking(True) > buttonss = HoverButton(button) > button.setIconSize(QtCore.QSize(200,200)) > widget.show() > sys.exit(app.exec_())
Hi uahmed, neither your description nor your code expresses your issue properly. Here's a simpler version, that might be helpful: from PyQt4 import QtGui, QtCore from PyQt4.QtCore import pyqtSignal import os,sys class HoverButton(QtGui.QToolButton): def enterEvent(self,event): print("Enter") button.setStyleSheet("background-color:#45b545;") def leaveEvent(self,event): button.setStyleSheet("background-color:yellow;") print("Leave") app = QtGui.QApplication(sys.argv) button = HoverButton() button.show() sys.exit(app.exec_()) Pete _______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt