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 free
Forum Updated to NodeBB v4.3 + New Features

QTableWidget memory free

Scheduled Pinned Locked Moved Solved General and Desktop
qtablewidget
3 Posts 2 Posters 1.9k 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.
  • V Offline
    V Offline
    vinothrajendran4
    wrote on last edited by
    #1

    I have a TableWidget in which i have allocated some rows using setRowCount().
    In this row i have added QSpinBox Widget inside TableWIdget Cell using setCellWidget()...
    My doubt is if i delete rows using deleteRow(), those widgets i have added inside those cells (QSpinBox) will get deleted or it may lead to memory leak....I have given parent for QSpinBox as "this" pointer..

    1 Reply Last reply
    0
    • jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      As stated in the documentation (http://doc.qt.io/qt-5/qtablewidget.html#setCellWidget):
      "Sets the given widget to be displayed in the cell in the given row and column, passing the ownership of the widget to the table."
      That means if you add a widget using setCellWidget() then the ownership is passed to the table, so the table is responsible for freeing memory. I think if you delete the row then all widgets will be deleted automatically.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • V Offline
        V Offline
        vinothrajendran4
        wrote on last edited by
        #3

        @jsulm : Thanks for ur reply.....My doubt is cleared.

        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