Hi, I want to subclass QTreeWidgetItem and use it within a QTreeWidget subclass, but I do not want to reimplement all functions from QTreeWidgetItem nore QTreeWidget.

So far so god.

Additionally I need the option to dynamically update the TreeWidget.

I create a method to search for applicable TreeWidgetItems:



Qt Code:
  1. /*! search from root (if root is zer0, search all nodes) all children for the Desired Drawable
  2.  */
  3. TreeWidgetItem* TreeWidget::deepSearchByPtr(TreeWidgetItem *root, Drawable *d){
  4. qDebug() << "DFS 0";
  5. if (root == 0){
  6. }
  7. else if (reinterpret_cast<Drawable*>(root->ptr()) == d){
  8. qDebug() << "DFS B";
  9. return root;
  10. }
  11.  
  12. qDebug() << "DFS C";
  13. TreeWidgetItem *ret;
  14. TreeWidgetItem *child;
  15. qDebug() << "DFS D";
  16. int count(0);
  17. if (root==0){
  18. count = invisibleRootItem()->childCount();
  19. }
  20. else{
  21. count = root->childCount();
  22. }
  23. for(int q(0); q<count; ++q){
  24. qDebug() << "DFS LOOP A";
  25. child = reinterpret_cast<TreeWidgetItem*>(root->child(q));
  26. qDebug() << "DFS LOOP B";
  27. if (child == NULL){
  28. qDebug() << "DFS LOOP C";
  29. continue;
  30. }
  31. qDebug() << "DFS LOOP D";
  32. ret = deepSearchByPtr(child, d);
  33. qDebug() << "DFS LOOP E";
  34. if (ret != NULL){
  35. qDebug() << "DFS LOOP F";
  36. return ret;
  37. }
  38. }
  39.  
  40. return NULL;
  41. }
To copy to clipboard, switch view to plain text mode 

The Problem with that is, that it fails right before
Qt Code:
  1. qDebug() << "DFS LOOP B";
To copy to clipboard, switch view to plain text mode 
though all children actually are TreeWidgetItem s.

Note: falling back to QTreeWidgetItems is not an option, as they hold way more data than ptr.

Note:
My Custom Type is called "TreeWidgetItem" and "TreeWIdget"

can anybody plx help me to fix this issue.

Sincerely

soxs060389

P.S. allready wasted hours on that subject...