[PyQt] SplashScreen and mousePressEvent
projetmbc
projetmbc at club-internet.fr
Thu Apr 9 08:28:21 BST 2009
Thanks, I'll try to understand that. Maybe my problem is a problem of
windowflag. Where are all the avaibale windowflag ?
Best reagrds and a great thanks for your help.
Christophe.
> Apologies for the C++ code, we have an info label that displays text
> in a popup QFrame, this is the method that sets the text and makes the
> widget visible.
>
> The things you will find interesting are mapping from the cursor to
> the current frame and then mapping this point (after moving out of the
> way of the mouse) to the mainwindow (which is the parent of the Qframe).
>
> Hope this helps.
>
> void InfoLabel::SetInfoLabel( const std::string &s )
> {
> if (s.empty())
> {
> if (!_hidden)
> {
> hide();
> _hidden = true;
> }
> }
> else
> {
> QPoint pos = mapFromGlobal(QCursor::pos());
> setText(s.c_str());
> adjustSize();
>
> QPoint p(pos.x(), pos.y() - height());
> move(this->mapTo(parent(), p));
> raise();
>
> if (_hidden)
> show();
> else
> update();
>
> _hidden = false;
> }
> }
>
>
> On 4/8/09 11:40 AM, "projetmbc" <projetmbc at club-internet.fr> wrote:
>
> Brian Kelley a écrit :
> > You can have the same effect using a timer:
> >
> > class MyFrame(QFrame):
> > def __init__(self, parent, pixmapfile):
> > QFrame.__init__(self, parent,
> > Qt.X11BypassWindowManagerHint |
> > Qt.FramelessWindowHint |
> > Qt.WindowStaysOnTopHint | Qt.Tool )
> >
> > # do something with pixmapfile
> >
> > self.timer = QTimer()
> > self.connect( self.timer, QtCore.SIGNAL("timeout()"),
> > self, QtCore.SLOT("hide()") )
> >
> > def showEvent(self, evt):
> > self.timer.start(3000) # 3 seconds
> > QFrame.showEvent(self, evt)
> >
> >
> > On 4/8/09 9:39 AM, "projetmbc" <projetmbc at club-internet.fr> wrote:
> >
> > 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.
> > Qt.X11BypassWindowManagerHint | Qt.FramelessWindowHint |
> > > Qt.WindowStaysOnTopHint | Qt.Tool
> >
> I do the following changes but there is still a very little problem
> concerning the position of the frame. How can I do to use
> QtGui.QCursor.pos() so as to put the frame where the mouse is ?
> I've tried to use rect=QtCore.QRect(position,
> QtCore.QPoint(1000,1000)) and self.setFrameRect(rect) but it
> doesn't
> work.
>
> Christophe.
>
> ====
> Code
> ====
>
> class MyFrame(QtGui.QFrame):
> # Squelette donné par Brian Kelley sur la liste de PyQt.
> def __init__(self, parent, titre, pixmapfile, position):
> QtGui.QFrame.__init__(self, parent,
> QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.Tool)
> # QtCore.Qt.X11BypassWindowManagerHint |
> QtCore.Qt.FramelessWindowHint
> | QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.Tool
> self.setWindowTitle(titre)
>
> label = QtGui.QLabel(self)
> label.setPixmap(pixmapfile)
> label.show()
>
> self.timer = QtCore.QTimer()
> self.connect( self.timer, QtCore.SIGNAL("timeout()"),
> self,QtCore.SLOT("hide()") )
>
> def showEvent(self, evt):
> self.timer.start(10000) # 10 seconds
> QtGui.QFrame.showEvent(self, evt)
>
>
More information about the PyQt
mailing list