[PyQt] Mouse Hover Event small issue

uahmed gleam.uahmed at gmail.com
Tue Feb 21 19:48:09 GMT 2012


any help !


On Tue, Feb 21, 2012 at 7:27 AM, uahmed <gleam.uahmed at gmail.com> 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_())
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20120222/108159ea/attachment.html>


More information about the PyQt mailing list