On Feb 1, 2013, at 10:16 AM, André Somers <an...@familiesomers.nl> wrote:

> Op 1-2-2013 9:43, Bache-Wiig Jens schreef:
>> On Feb 1, 2013, at 8:52 AM, Иван Комиссаров <abba...@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.

You are right in that they both have their uses so calling it "superseded" was 
inaccurate. They are both available in the API. If you truly want to customise 
the entire delegate, including the branch indicators and selection color / 
behavior, QItemDelegate is what you want.

On the other hand if you primarily want to respect the native look and feel or 
a style sheet, you should try to use QStyledItemDelegate. It gives you less 
control but generally looks more native. The main difference is that you then 
only get to control the text or icon layout and/or the editor widget. In this 
particular case it sounds like this is what the user needs.

Regards,
Jens
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to