[PyQt] SplashScreen and mousePressEvent

Brian Kelley kelley at eyesopen.com
Wed Apr 8 13:20:51 BST 2009

First, get rid of the mousePressEvent since the Splashscreen closes by default when the user clicks on it.  Also, make sure you start the event loop otherwise qt can't detect mouse events.  (Note the following code won't stop the application, you may need to kill it afterwards)

from PyQt4 import QtGui
import sys
app = QtGui.QApplication(sys.argv)
pixmap = QtGui.QPixmap("splash.png")
splash = QtGui.QSplashScreen(pixmap)

On 4/8/09 7:56 AM, "projetmbc" <projetmbc at club-internet.fr> wrote:

I would like to close a splashscreen if the user clicks on it. I decide
to subclass QtGui.QSplashScreen to do that but the following code
doesn't catch the mouse press event. Why ?

Best regards.

The code

class mySplashScreen(QtGui.QSplashScreen):
    def __init__(self, pixmap):
        super(QtGui.QSplashScreen, self).__init__(pixmap)

    def mousePressEvent(self, event):
        print 'ok'

PyQt mailing list    PyQt at riverbankcomputing.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090408/880d4b94/attachment.html

More information about the PyQt mailing list