[PyQt] About paintEvent and semi-transparent background pixmap.

Gustavo A. Díaz gustavo.diaz at gmail.com
Mon Aug 27 18:58:21 BST 2007


Hi!!

Still i am trying to solve the semi-transparent backrground for my app,
which i've done this so far:

...
def showEvent(self, event):
        self.desktopBg =
QtGui.QPixmap.grabWindow(QApplication.desktop().winId(),
\
                self.geometry().x(),self.geometry().y(), self.rect().width(),
self.rect().height())

    def paintEvent (self, event):
        self.clientBgPixmap = QtGui.QPixmap
(":/Pixmaps/pixmaps/oc_clientBg.png")
        self.setMask(self.clientBgPixmap.mask())
        self.painter = QtGui.QPainter(self)
        self.painter.setRenderHint(QPainter.Antialiasing)
        self.painter.drawPixmap(0, 0, self.desktopBg)
        self.painter.drawPixmap(0, 0, self.clientBgPixmap)
        self.painter.end()
...

So i got a semi-transparent background (and of course,  the .png pixmap is
semi-transparent) but it only refresh what shines trough the background when
I hide and show my app (from my systray).

I've implemented too the drag and drop event so i could move my app with the
left button of the mouse:

def mousePressEvent(self, event):
            if event.button() == QtCore.Qt.LeftButton:
                    self.dragPosition = event.globalPos() -
self.frameGeometry().topLeft()
            event.accept()

        def mouseMoveEvent(self, event):
            if event.buttons() == QtCore.Qt.LeftButton:
                    self.move(event.globalPos() - self.dragPosition)
            event.accept()


Now, my question is, how i could update what shines trough the background
pixmap when i drop my app? (not necessary when i move it, just when i drop
it)

Thanks!!

Cheers.


-- 
Gustavo A. Díaz
GDNet Projects
www.gdnet.com.ar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20070827/a57b432c/attachment.html


More information about the PyQt mailing list