[Interest] Subclassing QTreeWidgetItem together with QObject

Igor Mironchik igor.mironchik at gmail.com
Fri Nov 27 17:15:28 CET 2015



On 27.11.2015 16:50, Andrej Kacian wrote:
> On Fri, 27 Nov 2015 12:35:56 +0300
> Igor Mironchik <igor.mironchik at gmail.com> wrote:
>
>> On 27.11.2015 12:19, Andrej Kacian wrote:
>>> Hello all,
>>>
>>> I have a class derived from QTreeWidgetItem, and would like it to
>>> be able to use Qt's signal/slot system.
>>>
>>> Since QTreeWidgetItem is not itself derived from QObject, can I
>>> safely inherit from QTreeWidgetItem and QObject at the same time?
>>> E.g.:
>>>
>>> class MyTreeWidgetItem: public QTreeWidgetItem, public QObject
>>> {
>>>     Q_OBJECT
>>>     ...
>>> }
>> I don't see technical problems here, but...
> Well, the one problem I see, after looking closer is that Both
> QTreeWidgetItem and QObject have parent() method, each different. It
> could be that these will overload nicely, but I am not sure about that.

It shouldn't be problems with this...

>
>>> Or is there a better way to do what I described?
>>>
>>> Thanks in advance,
>> Can you point out to what the signals/slots do you want to have?
> I just need one slot in it to be able to trigger update of displayed
> columns for that item/row in the treeview.
>
> Regards,

As André Somers wrote why not to implement custom model for this? ...

-- 
Best Regards,
Igor Mironchik.




More information about the Interest mailing list