Op 27/11/2015 om 10:19 schreef Andrej Kacian:
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
   ...
}
Well, you will need to reverse the two. The QObject needs to be the first of the two. Other than that, there are no reasons that won't work.
Or is there a better way to do what I described?

Perhaps, depending on what you really want to achieve. Instantiating QObjects everywhere is quite expensive. If you have a lot of items in your tree, it may cause performance issues.

André

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

Reply via email to