Hi. Want an image (QPixmap) as background of my QTreeView fixed in the
lower right corner of the viewport at all times.  Did this for a QTableView
by installing an event filter and drawing the pixmap when I receive Paint
events on the viewport.  This doesn't seem to work for the QTreeView,
resizing the window still works but scrolling breaks up the image.  My
QTreeView eventFilter code is below:

    def eventFilter(self, obj, ev):

        if ev.type() == QEvent.Paint and obj == self.viewport():
            h = self.pixmap.rect().height()
            w = self.pixmap.rect().width()
            r = self.viewport().rect()

            x = r.right() - w
            if self.verticalScrollBar().isVisible(): x +=
self.verticalScrollBar().width()
            r.setX(x)
            r.setWidth(w)

            y = r.bottom() - h + self.horizontalScrollBar().height() - 17
            if self.horizontalScrollBar().isVisible(): y +=
self.horizontalScrollBar().height()
            r.setY(y)
            r.setHeight(h)

            QStylePainter(obj).drawItemPixmap(r, Qt.AlignRight, self.pixmap)

        return super(TreeView, self).eventFilter(obj, ev)
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to