Results 1 to 2 of 2

Thread: Does clear()/clearContents() delete items?

  1. #1
    Join Date
    Dec 2007
    Location
    Austin, TX
    Posts
    43
    Thanks
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Wink Does clear()/clearContents() delete items?

    I know I'm probably going to feel stupid, but after searching the docs & the forums, I couldn't find an answer to this (and don't have the .cpp files for Qt with the company install)...

    When you do a clear() or clearContents() on a QTableWidget (or QTreeWidget), does it delete the QTableWidgetItems in the table? (I sort of assume that widgets in the table might not be deleted, but I'm thinking about the fairly simple implementation.) Currently, I iterate through the rows/columns, take the item & delete it -- but if I can cut down on this "duplicative effort" I could probably get things finished sooner (and still no memory leaks )

    Thanks all,
    Vycke

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Does clear()/clearContents() delete items?

    QTreeWidget::clear() does delete the items too. I had tested it once. And may be QTableWidget also does the same.

    Anyways u can easily verify it. Just subclass the QTreeWidgetItem and QTableWidgetItem, and put a breakpoint in the destructor. Call the clear or clearContents and see if the breakpoint is reached

Similar Threads

  1. Delete items retrieved from QTreeWidget.takeItem
    By bruccutler in forum Qt Programming
    Replies: 3
    Last Post: 22nd March 2007, 23:24
  2. When is the best time to delete a QCanvasItem
    By irudkin in forum Qt Programming
    Replies: 12
    Last Post: 8th March 2007, 21:28
  3. c++, placement delete upon exception
    By stinos in forum General Programming
    Replies: 6
    Last Post: 31st October 2006, 15:38
  4. delete items from list box
    By vvbkumar in forum Qt Programming
    Replies: 4
    Last Post: 23rd June 2006, 19:08
  5. Selective highlighting of Items
    By Kapil in forum Qt Programming
    Replies: 3
    Last Post: 26th May 2006, 12:20

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.