I'm trying to add a QGraphicsEffect
to a QAbstractItemView
(could be a QListView
, QTableView
, it should be similar for all of them) in Qt (using PySide2 in Python 2.7, but should apply to any language with Qt).
I have a suspicion that due to the way the item view widgets render themselves on a per-item basis with render delegates etc etc, that they won't play nicely and there isn't a solution. I can't find a reference to it explicitly NOT working in the docs, so it seems like it should work (I mean, they are subclasses of QWidget
, which does support QGraphicsEffect
s. Seems like a possible oversight in implementation/documentation). Can anyone confirm or help with the correct way to do or workaround this?
Example that demonstrates with a blur effect:
from PySide2 import QtWidgets, QtGui, QtCore
lw = QtWidgets.QListWidget()
lw.addItems(["dog", "cat", "fish", "platypus"])
lw.show()
ge = QtWidgets.QGraphicsBlurEffect()
lw.setGraphicsEffect(ge)
ge.setBlurRadius(20)
btn = QtWidgets.QPushButton("so fuzzy!")
btn.show()
ge = QtWidgets.QGraphicsBlurEffect()
btn.setGraphicsEffect(ge)
ge.setBlurRadius(20)
Screenshot:
You have to apply effect to the viewport: