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. QTableWidget memory management
Forum Update on Tuesday, May 27th 2025

QTableWidget memory management

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 213 Views
  • 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.
  • F Offline
    F Offline
    FuzzieTheWarg
    wrote on 26 Apr 2023, 12:00 last edited by
    #1

    Does QTableWidget::setHorizontalHeaderItem() take ownership of the item that is set?
    The docs state that setItem() does take ownership, but is silent about the header item.

    J 1 Reply Last reply 26 Apr 2023, 12:17
    0
    • F FuzzieTheWarg
      26 Apr 2023, 12:00

      Does QTableWidget::setHorizontalHeaderItem() take ownership of the item that is set?
      The docs state that setItem() does take ownership, but is silent about the header item.

      J Offline
      J Offline
      JonB
      wrote on 26 Apr 2023, 12:17 last edited by JonB
      #2

      @FuzzieTheWarg
      You can assume it does, since it deletes any item already there. But I can't show you a doc stating this for setHorizontalHeaderItem() per se.

      1 Reply Last reply
      1
      • F Offline
        F Offline
        FuzzieTheWarg
        wrote on 19 Jun 2023, 21:19 last edited by
        #3

        I wanted more proof, so I went digging. Header Items are deleted when the QTableModel is deleted. Here's a pictorial stack trace for posterity.

        f7f66fae-1270-4f9b-bcc9-6eaca1918a67-image.png

        788e91c8-bf1e-426b-989a-8007acc4c99d-image.png

        bbf79342-0e45-4f06-ab74-7e24b543fe92-image.png

        fe832086-fc28-473b-b5e2-2cc49ed6177d-image.png

        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