[Qt] Problems with OwnerDraw ListWidget and friends

Paul Ishenin ip at kmiac.ru
Fri Jul 20 07:35:06 CEST 2007


Paul Ishenin wrote:
> Hello,  Items specific to the Qt widget set.
> 
> In LCL we have many item containers that can have custom draw item events.
> 
> To implement this functionality I suposed it will be enough to listen 
> painEvent and call draw item events while traversing items.
> 
> But qt suggest anther approach for that - override 
> QAbstractItemDelegate. We already have QComboBox_setItemDelegate, 
> QAbstractItemView_setItemDelegate and so on. We only need our own delegate.
> 
> I dont think it is not possible to subclass QAbstractItemDelegate in 
> pascal. So we need this thing in bindings.
> 
> We only should override 2 methods: paint and sizeHint at moment to 
> achive needed result.
> 
> We need that paint and sizeHint methods redirect calls to our own 
> methods. We can for example use constructor and pass that methods as 
> arguments or we can use getters and setters.
> 
> For example:
> 
> Delegate := QPascalItemDelegate_create(@PaintHook, @SizeHintHook);
> QComboBox_setItemDelegate(Delegate);
> ...
> 
> Den, what do you think. Is it possible?
> 

It will be even better to override QItemDelegate instead of 
QAbstractItemDelegate. Sice QItemDelegate already has default 
implementation we can turn it on if we will not process that painting 
ourself.

Best regards,
Paul Ishenin.




More information about the Qt mailing list