[PyQt] Catching mouseclicks outside QPopup

Giovanni Bajo rasky at develer.com
Fri Feb 22 19:03:15 GMT 2008


On 2/22/2008 7:28 PM, Peter Shinners wrote:

> I have a custom QTextEdit widget opened as a QPopup. How can my widget
> catch mouse clicks outside the widget area so it knows when to hide? I
> want the same behavior as clicking outside a QMenu or QComboBox popup.
> It seems like there would be some window flag I can set to do this
> automatically? I've found grabMouse doesn't quite work, and also sets
> off alarms from the desktop protection apps.

Add a custom exec() function to your class and run a custom event loop 
in there (QEventLoop.exec). I'm not 100% sure it will work, but it should.
-- 
Giovanni Bajo



More information about the PyQt mailing list