Results 1 to 6 of 6

Thread: Does QTableWidget::clear() delete pointers?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Does QTableWidget::clear() delete pointers?

    Yes, as you can see in the sources:
    Qt Code:
    1. void QTableModel::clear()
    2. {
    3. for (int j = 0; j < verticalHeaderItems.count(); ++j) {
    4. if (verticalHeaderItems.at(j)) {
    5. verticalHeaderItems.at(j)->view = 0;
    6. delete verticalHeaderItems.at(j);; // <--
    7. verticalHeaderItems[j] = 0;
    8. }
    9. }
    10. for (int k = 0; k < horizontalHeaderItems.count(); ++k) {
    11. if (horizontalHeaderItems.at(k)) {
    12. horizontalHeaderItems.at(k)->view = 0;
    13. delete horizontalHeaderItems.at(k);; // <--
    14. horizontalHeaderItems[k] = 0;
    15. }
    16. }
    17. clearContents();
    18. }
    19.  
    20. void QTableModel::clearContents()
    21. {
    22. for (int i = 0; i < tableItems.count(); ++i) {
    23. if (tableItems.at(i)) {
    24. tableItems.at(i)->view = 0;
    25. delete tableItems.at(i); // <--
    26. tableItems[i] = 0;
    27. }
    28. }
    29. reset();
    30. }
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to Lykurg for this useful post:

    Neptilo (24th June 2013)

Similar Threads

  1. QTableWidget & cellWidget : some pointers
    By prashant in forum Qt Programming
    Replies: 1
    Last Post: 18th October 2009, 10:48
  2. Replies: 2
    Last Post: 13th May 2009, 10:35
  3. Does clear()/clearContents() delete items?
    By vycke in forum Qt Programming
    Replies: 1
    Last Post: 31st July 2008, 17:49
  4. Replies: 1
    Last Post: 14th May 2008, 19:35
  5. How to delete header on QTableWidget
    By jlbrd in forum Qt Programming
    Replies: 2
    Last Post: 18th July 2006, 21:00

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
  •  
Qt is a trademark of The Qt Company.