i hope it's ok to ask pyqt questions here 
in my paint method for my delegate i do this:
text = index.model().data(index).toString()
txtEdit.clear()
txtEdit.setDefaultTextOption(txtOption)
txtEdit.setDefaultFont(option.font)
if option.
state & QtGui.
QStyle.
State_Selected: txtEdit.
setHtml(QtCore.
QString(text
)) else:
txtEdit.setHtml(text)
txtEdit.
setPageSize(QtCore.
QSizeF(option.
rect.
size()))
if option.
state & QtGui.
QStyle.
State_Selected: # selected state color
color = palette.highlight().color()
print color.red(), color.green(), color.blue()
else:
# normal state color
# find the current backgroundColor
color
= QtGui.
QColor(index.
model().
data(index, QtCore.
Qt.
BackgroundColorRole)) print "not selected"
print color.red(), color.green(), color.blue()
text = index.model().data(index).toString()
palette = QtGui.QApplication.palette()
txtEdit = QtGui.QTextDocument()
txtEdit.clear()
txtOption = QtGui.QTextOption()
txtOption.setWrapMode(QtGui.QTextOption.NoWrap)
txtEdit.setDefaultTextOption(txtOption)
txtEdit.setDefaultFont(option.font)
if option.state & QtGui.QStyle.State_Selected:
txtEdit.setHtml(QtCore.QString(text))
else:
txtEdit.setHtml(text)
txtEdit.setPageSize(QtCore.QSizeF(option.rect.size()))
if option.state & QtGui.QStyle.State_Selected:
# selected state color
color = palette.highlight().color()
print color.red(), color.green(), color.blue()
else:
# normal state color
# find the current backgroundColor
color = QtGui.QColor(index.model().data(index, QtCore.Qt.BackgroundColorRole))
print "not selected"
print color.red(), color.green(), color.blue()
To copy to clipboard, switch view to plain text mode
so i basicly create a textDocument widget. when i startet small and just put in the text when i saw the text items overlapping each other when i resize columns. so i came at the end to the code above which draws a rectangle with a color. now, my tree is set with alternating colors. so i can't just use one fixed color and need to figure out the background color of the current line where im in. i can't find a way to get the current background color from my delegate.
anyone knows the answer to this or maybe to even avoid drawing the rectangle all together and avoid the overlapping text ?
thanks in advance
Bookmarks