[PyQt] QTreeView with floating background image
Marc Rossi
mrossi19 at gmail.com
Tue Jan 17 02:20:10 GMT 2012
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)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20120116/6bb70fc8/attachment.html>
More information about the PyQt
mailing list