[Interest] ItemDelegate and word wrapping

André Somers andre at familiesomers.nl
Fri Feb 1 10:16:46 CET 2013


Op 1-2-2013 9:43, Bache-Wiig Jens schreef:
> 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
>
Actually, I found that QStyledItemDelegate makes it even _harder_ to do 
this. Where QItemDelegate had a range of virtual protected functions 
that were responsible for drawing part of the delegate (so you could 
easily opt to only re-implement one and simply re-use the rest) 
QStyledItemDelegate doesn't help you with the rendering of these kinds 
of elements at all. You're just left to your own devices, using ugly 
hacks to get the base implementation to do part of the rendering for you.

André




More information about the Interest mailing list