QTableWidget memory free
-
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.. -
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. -
@jsulm : Thanks for ur reply.....My doubt is cleared.