Details
-
Suggestion
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
5.14.1
-
None
-
Windows 7
Python 2.7
PySide2/PySide/PyQt5/PyQt4
Description
There seems to be no easy way to draw elided item text inside of a QStyledItemDelegate with QStyle. If all I want to do is draw text in a tree/table view cell exactly as the default implementation would, but just change the position or width of the text, it requires a TON of boilerplate code to get that working.
I tried copying the source code for the default implementation of QStyledItemDelegate::paint, but even this resulted in a dead-end. This method calls QStyle::drawControl with the QStyle::CE_ItemViewItem case. This then calls d->viewItemDrawText(p, vopt, textRect); The problem with that is it's calling private code. I don't have any way of drawing the text using the Qt way other than messing with Qt internals or copying source code which can become outdated with a new Qt release.
Please expose a way to simply draw elided text for a tree/table view item.