I'm attempting to do a display a table with an icon as the background for each cell (the cell values will be either true or false, and ultimately, I want a red icon for false and some other icon for true.)
(probably could do it with background color, but I wanted a bit more "look" to it...)

So I've got it displaying a icon, but, I can't seem to get it to just fill the cell.

I specifically set the cell height and width
Qt Code:
  1. self.tableView.setRowHeight(64), self.tableView.setColumnWidth(64)
To copy to clipboard, switch view to plain text mode 
which doesn't seem to work. (It appears to size to the data)

And the icon is duplicated, but only partially shown (I can see the top part and the top left of the second copy.

The data and setdata methods from my model are shown below. (I can never figure out from the QT docs what I what's nice to do, what has to be done, the minimum requirements, etc. so these are probably far from complete... )

Qt Code:
  1. def data(self, index, role): # Return data from the model
  2. if not index.isValid():
  3. print('Invalid index in MyModel>data')
  4. retval = QtCore.QVariant()
  5. elif role == QtCore.Qt.BackgroundRole:
  6. retval = QtGui.QPixmap('/home/mac/SharedData/PycharmProjs/MuteMap/Mute_dark.png')
  7. elif role == QtCore.Qt.DisplayRole:
  8. retval = QtCore.QVariant(self.arraydata[index.row()][index.column()])
  9. else:
  10. retval = QtCore.QVariant()
  11.  
  12. return retval
  13.  
  14. def setData(self, index, value, role): # Set data in the model
  15. if role == QtCore.Qt.EditRole and index.isValid():
  16. print(index.row())
  17. self.arraydata[index.row()][index.column()] = value
  18. print('Return from rowCount: {0}'.format(self.rowCount(index)))
  19. self.dataChanged.emit(index, index, [QtCore.Qt.DisplayRole])
  20. return True
  21. return False
To copy to clipboard, switch view to plain text mode