[PyQt] Re: how to implement hover event ?

Jean-Baptiste BUTET ashashiwa at gmail.com
Sat Jan 5 16:08:00 GMT 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all :)

I answer myself here, in order someone needs this.

key word is setMouseTracking !!

here is a widget (QLabel) I call just after creation of the widget I need.


class Hover(QtGui.QLabel):
    def __init__(self, parent):
        QtGui.QLabel.__init__(self,parent)

self.setGeometry(QtCore.QRect(10,60,640,480))
        self.setMouseTracking(1)

    def mouseMoveEvent(self, event):
        print "on Hover",
event.pos().x(), event.pos().y()

Clear skies,

JB




-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: http://firegpg.tuxfamily.org

iD8DBQFHf6onetOZWwsO2AERAr7yAJ97SDmwA5MZrGAR3aepHUGN96iMmQCgiqeP
kdJ87+GZ/+yvlgEsEvR/AW8=
=P1Rw
-----END PGP SIGNATURE-----
2008/1/4, Jean-Baptiste BUTET <ashashiwa at gmail.com>:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi all :)
>
> I'm trying to do this :
> - -> when mouse is on a label, position ou cursor should be given.
>
> so i've done a :
> def enterEvent(self, event):
>         a = QtGui.QHoverEvent()
>         x = a.pos(self)
>
> - -> Errors :
>     a = QtGui.QHoverEvent()
> TypeError: insufficient number of arguments to QHoverEvent()
>
> So i've consulting :
> http://docs.huihoo.com/pyqt/pyqt4/html/qhoverevent.html
>
> but don't understand how to implement it...
>
> Someone to help me, please ? :)
>
> JB
>
> - --
> http://astrolix.org
> association des linuxiens astronomes
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.7 (GNU/Linux)
> Comment: http://firegpg.tuxfamily.org
>
> iD8DBQFHfoZGetOZWwsO2AERAoEJAJ9Tnhmf0ziEzy+OHKSylAfqYNwGPACgwaD8
> esrWStltSpkIHhBN5jPGfFM=
> =nfNU
> -----END PGP SIGNATURE-----
>
>
>


-- 
http://astrolix.org
association des linuxiens astronomes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20080105/9c81e9b5/attachment.html


More information about the PyQt mailing list