The fader widget is limited. What you really want to do is create a parent 
QWidget or QStackedWidget subclass and have it call render() on both widgets, 
then fade with one on top of the other with the one being faded to on the 
bottom (by decreasding the opacity of the top) until it is complete them move 
it to the current stack item.

That is for a cross fade. You could always fade to empty then fade out. 



----- Original Message ----
From: Nicola Murino <li...@svrinformatica.it>
To: pyqt@riverbankcomputing.com
Sent: Tuesday, August 18, 2009 11:25:31 AM
Subject: [PyQt] Fade effect a widget on top of another widget

Hi all,

I'm trying to make a fade effect as explained here:

http://doc.trolltech.com/qq/qq16-fader.html
http://labs.trolltech.com/blogs/2007/08/21/fade-effects-a-blast-from-the-past/

I have a main windows and I change the centralwidget on some user action so I 
do somenthing like:

self.setCentralWidget(newwidget)

I would like to have a fade effect on widget change so I tryed to do a 
FaderWidget and call something like:

self.setCentralWidget(FaderWidget(newwidget))

this is my not working attempt for FaderWidget:

class widgetFader(QWidget):
    def __init__(self,faded,parent=None):
        super(widgetFader,self).__init__(parent)
        faded.setupUi(faded)
        self.timeline=QTimeLine(3000,self)
        self.connect(self.timeline,  SIGNAL("frameChanged(int)"), 
SLOT("update()"))
        self.timeline.setFrameRange(0,100)
        self.timeline.setCurveShape(QTimeLine.EaseInOutCurve)
        if faded:
            self.startBrush=faded.palette().window()
        else:
            self.startBrush=Qt.white
        
    def startAnimation(self):
        self.timeline.start()
        
    def paintEvent(self,event):
        painter=QPainter(self)
        frame=self.timeline.currentFrame()
        #print frame/100.0
        painter.setOpacity(frame/100.0)
        painter.fillRect(self.rect(),self.startBrush)
        if frame>=100:
            self.close()

what's wrong? waht is the right way to have a fader widget?

thanks
Nicola
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt



      
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to