Hello!
Below, you get an executable piece of code to demonstrate the
possibility of setting the background color for a specific cell. This is
the shortest possibility, but yours would also work with the following
additional line:
br.setStyle(QtCore.Qt.BrushStyle.SolidPattern)
Because, at the moment, your brush has BrushStyle.NoBrush and as the
name says, there will be no brush...
Hope this helps!
Aaron
from PySide.QtGui import *
from PySide.QtCore import *
import sys
class ColorFileSystemModel(QFileSystemModel):
def data(self, index, role):
if role == Qt.BackgroundRole and index.row() == 0 and
index.column() == 0:
return QBrush(QColor(255, 0, 0, 127))
else:
return super(ColorFileSystemModel, self).data(index, role)
if __name__ == '__main__':
app = QApplication(sys.argv)
model = ColorFileSystemModel()
model.setRootPath(QDir.currentPath())
tree = QTreeView()
tree.setModel(model)
tree.show()
sys.exit(app.exec_())
_______________________________________________
PySide mailing list
[email protected]
http://lists.pyside.org/listinfo/pyside