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. [SOLVED]will clear also delete all the QTreeWidgetItem/QListWidgetItem?

[SOLVED]will clear also delete all the QTreeWidgetItem/QListWidgetItem?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 3.0k Views 2 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 opengpu2
    #1

    will clear also delete all the QTreeWidgetItem/QListWidgetItem?
    i found there is takeChildren in QTreeWidgetItem, but there is only item/takeItem in QListWidget, no items()/takeItems()......

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Yes. The items will be deleted by clear() as stated in the docs.

      QTreeWidget has takeTopLevelItem and each item has takeChild / takeChildren.
      QListWidget has takeItem and it's a flat structure. List items don't have children so there's nothing there to take.

      1 Reply Last reply
      0
      • O Offline
        O Offline
        opengpu2
        wrote on last edited by
        #3

        i mean there is no takeItems in QListWidget :) i want all the items.

        1 Reply Last reply
        0
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4
          while(auto item = listWidget->takeItem(0)) {
             //do something with item
          }
          
          1 Reply Last reply
          0
          • O Offline
            O Offline
            opengpu2
            wrote on last edited by
            #5

            thank you

            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