[PyQt] SplashScreen and mousePressEvent

projetmbc projetmbc at club-internet.fr
Wed Apr 8 14:39:01 BST 2009


Brian Kelley a écrit :
> The splashscreen is probably not what you want. You can make a QFrame 
> and apply the following styles
>
> QFrame( parent, Qt.X11BypassWindowManagerHint | Qt.FramelessWindowHint |
> Qt.WindowStaysOnTopHint | Qt.Tool )
>
> You will need to override the mouseClickEvent to close this window.
>
> To place it you can get the mouse’s x,y position when right clicking 
> on the tree node and create the frame (with the appropriate images 
> inside) and then place it appropriately.
>
> Brian
>
>
> On 4/8/09 8:41 AM, "projetmbc" <projetmbc at club-internet.fr> wrote:
>
>     Ok. Thanks a lot for the informations. I've tried another method
>     and it
>     works well. Indeed I use a SplashScreen to show a single picture
>     associated to a node in a TreeWidget when the user does a right
>     click on it.
>
>     A last question. Is it possible to choose the position where the
>     SplashScreen appears ?
>
>     Christophe.
>
>
>
>
>     Brian Kelley a écrit :
>     > 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)
>     > splash.show()
>     > app.exec_()
>     >
>     >
>     > On 4/8/09 7:56 AM, "projetmbc" <projetmbc at club-internet.fr> wrote:
>     >
>     > Hello,
>     > 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.
>     > Christophe
>     >
>     > ======
>     > 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
>     > http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>     >
>
>
>
You're right. I will try to do that with a frame but the adventage of a 
SplashScreen is that it lives for a laps of time.

Best regards.
Christophe.



More information about the PyQt mailing list