[Interest] ItemDelegate and word wrapping

Иван Комиссаров abbapoh at gmail.com
Fri Feb 1 08:52:21 CET 2013


Hello. I'm trying to implement a delegate with QTextOption::WrapAtWordBoundaryOrAnywhere. I copied QItemDelegate and replaced QTextOption::WordWrap where needed. Also i made small fix for sizeHint() calculation. Everything is ok, except that QItemDelegate doesn't look native:)

I tried to call style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, widget); with empty text and icon to draw "fancy" winvista/oxygen selection. It works too, but only these 2 styles. QMacStyle and QWindowsStyle doesn't have such "fancy" selection and i need to draw selection manually (filling text rect with QPalette::Highlight color).
As a result, i see both "fancy" and usual selections painted in oxygen/vista styles.

The only solution i can imagine is to hardcode style names and draw Highlight rect only if style name != "oxygen"/"windowsvista", but that looks bad.

I also tried to use proxy style and reimplement QStyle::drawItemText, but it appears that Oxygen style doesn't call this method (correct me, if i'm wrong).

Can anyone tell me if I'm on the right way, or i should do something completely different to achieve native items with WordWrapAnywhere?

Иван Комиссаров

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130201/e004a912/attachment.html>


More information about the Interest mailing list