Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I know if the mouse is over the widget?

I am fairly new to Qt (PyQt - PySide).
I am trying to build a custom widget which is a menu. However I have hit a hard road and I can not seem to be able to sort myself out. I've read the documentation but I don't think there is a mouse state I can verify to find out if mouse cursor is over the given widget.

I am calling a function upon the mouseReleaseEvent of a QWidget.

Ex.:

def mouseReleaseEvent(self, e):     

When this event is triggered, I have to know if the mouse is actually over the widget or outside of it (the widget of which this event is triggered).

    if mouseCursorOverSelf == True:
        # do something ..

How can I achieve this? What do I need to do?

Thank you very much!

like image 785
Phil Avatar asked Dec 30 '12 14:12

Phil


1 Answers

underMouse() is what should be used to determine whether your mouse is over a widget.
Usage: widget.underMouse()
http://pyqt.sourceforge.net/Docs/PyQt4/qwidget.html#underMouse

like image 187
David Lannan Avatar answered Oct 02 '22 22:10

David Lannan