I'm trying to use custom items in QTreeWidget. e.g:
tree_item.h Code:
  1. #include <QTreeWidgetItem>
  2. #include "unit.h" // header with any class
  3.  
  4. class tree_item : public QTreeWidgetItem
  5. {
  6. public:
  7. tree_item(unit *object);
  8.  
  9. unit *object() const;
  10. // ...
  11. };
To copy to clipboard, switch view to plain text mode 
tree_item.cpp Code:
  1. #include "tree_item.h"
  2.  
  3. tree_item::tree_item(unit *object)
  4. : QTreeWidgetItem(SOME_USER_TYPE)
  5. {
  6. setText(0, *(object->name()));
  7. }
  8.  
  9. // ...
To copy to clipboard, switch view to plain text mode 

I can add my custom item to a QTreeWidget. But when I'm trying to get it back, tree is returning item of type QTreeWidgetItem.. In short, I'm loosing data

main.cpp Code:
  1. // ...
  2.  
  3. QTreeWidget *tree = new QTreeWidget();
  4. tree_item *item = new tree_item(new unit(10, 12));
  5. tree->addTopLevelItem(item);
  6.  
  7. // ...
To copy to clipboard, switch view to plain text mode 

This part of code works properly, I can see my object's name in column 0. But if I use,
for example: tree->itemAt(some_point) of course it gives me item of type QTreeWidgetItem* not tree_item*

Can someone give me ideas? (If possible, without inheriting QTreeWidget)

Thanks in advance