I made (with numbat's help) a delegate for drawing items in a qtreeview. But now I have another problem with the delegate.



Do you see the border line (1px) that is a little bit darker than the color around it? It should be drawn at the very left part of the item. Instead of that the delegate draws the item (at the right) and some kind of square (at the left).

And if I set border-radius (rounded borders) in the stylesheet, I get rounded borders on the item and on the square.

How can I make it draw everything as just one item?

Delegate code:

Qt Code:
  1. def paint(self, painter, option, index):
  2. if not index.isValid():
  3. return
  4. options = QStyleOptionViewItemV4(option)
  5. self.initStyleOption(options, index)
  6. painter.save()
  7. painter.setRenderHint(QPainter.Antialiasing, True)
  8. doc = QTextDocument()
  9. doc.setHtml(options.text)
  10. options.text = ""
  11. options.widget.style().drawControl(QStyle.CE_ItemViewItem, options, painter, options.widget)
  12. painter.translate(options.rect.left(), options.rect.top())
  13. rect = QRectF(0, 0, options.rect.width(), options.rect.height())
  14. doc.drawContents(painter, rect)
  15. painter.restore()
To copy to clipboard, switch view to plain text mode 

Thanks