Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. what is the best way to delete all childWidgetItem of QTreeWidgetItem recursively?
Forum Updated to NodeBB v4.3 + New Features

what is the best way to delete all childWidgetItem of QTreeWidgetItem recursively?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 636 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    opengpu2
    wrote on last edited by
    #1

    what is the best way to delete all childWidgetItem of QTreeWidgetItem recursively?
    thank you!

    A 1 Reply Last reply
    0
    • O opengpu2

      what is the best way to delete all childWidgetItem of QTreeWidgetItem recursively?
      thank you!

      A Offline
      A Offline
      aliks-os
      wrote on last edited by
      #2

      @opengpu2

      void MainWindow::delItemInTree(QTreeWidgetItem *item) {
          if (item == 0) return;
          QTreeWidgetItem *itemAbove = ui->treeWidget->itemAbove(item);
          if (itemAbove == 0) return;
          QTreeWidgetItem *parent = item->parent();
          while (item->childCount() > 0) {
              QTreeWidgetItem *tmp = item->takeChild(0);
              tmp = 0;
              delete tmp;
          }
          int index = parent->indexOfChild(item);
          delete parent->takeChild(index);
      }
      
      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved