Details
-
Type:
Suggestion
-
Status: Reported
-
Priority:
Not Evaluated
-
Resolution: Unresolved
-
Affects Version/s: 5.14.1
-
Fix Version/s: None
-
Component/s: GUI: Font handling, GUI: Look'n'Feel, GUI: Painting, GUI: Text handling
-
Labels:None
-
Environment:
Windows 7
Python 2.7
PySide2/PySide/PyQt5/PyQt4
-
Platform/s:
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.