alexandernst
8th August 2009, 18:47
I made (with numbat's help) a delegate for drawing items in a qtreeview. But now I have another problem with the delegate.
http://img19.imageshack.us/img19/9328/delegate1.jpg
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:
def paint(self, painter, option, index):
if not index.isValid():
return
options = QStyleOptionViewItemV4(option)
self.initStyleOption(options, index)
painter.save()
painter.setRenderHint(QPainter.Antialiasing, True)
doc = QTextDocument()
doc.setHtml(options.text)
options.text = ""
options.widget.style().drawControl(QStyle.CE_ItemV iewItem, options, painter, options.widget)
painter.translate(options.rect.left(), options.rect.top())
rect = QRectF(0, 0, options.rect.width(), options.rect.height())
doc.drawContents(painter, rect)
painter.restore()
Thanks
http://img19.imageshack.us/img19/9328/delegate1.jpg
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:
def paint(self, painter, option, index):
if not index.isValid():
return
options = QStyleOptionViewItemV4(option)
self.initStyleOption(options, index)
painter.save()
painter.setRenderHint(QPainter.Antialiasing, True)
doc = QTextDocument()
doc.setHtml(options.text)
options.text = ""
options.widget.style().drawControl(QStyle.CE_ItemV iewItem, options, painter, options.widget)
painter.translate(options.rect.left(), options.rect.top())
rect = QRectF(0, 0, options.rect.width(), options.rect.height())
doc.drawContents(painter, rect)
painter.restore()
Thanks