[Interest] ItemDelegate and word wrapping

Bache-Wiig Jens Jens.Bache-Wiig at digia.com
Fri Feb 1 09:43:58 CET 2013


On Feb 1, 2013, at 8:52 AM, Иван Комиссаров <abbapoh at gmail.com> wrote:

> 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 don' know if it will resolve this particular issue, but QItemDelegate was superseded by QStyledItemDelegate for exactly that reason. I would suggest trying that instead.

http://qt-project.org/doc/qt-4.8/qstyleditemdelegate.html

Regards,
Jens

	

> 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?
> 
> Иван Комиссаров
> 
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest




More information about the Interest mailing list