Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[SOLVED] Proper way to remove Rows from a QTableWidget
darkp03 last edited by darkp03
I Have a doubt about how memory usage works with QTableWidgets.
Lets assume I have a TableWidget, and in one cell I Have a QTableWidgetItem, on another one a PushButton (with a proper connection).
I just want to know what are the proper steps to remove a Row, with those Widgets.
Should I just first delete/disconnect every item on every cell?
Or can I call
If I remove a Column/Row, do the destructors of each Widget get called? And is the memory released?
The documentation doesnt talk about what exactly happens with the items/widgets that are lost.
For example, in my particular case, the pushbuttons I place on my Table are connected via a QSignalMapper to a specific Slot. And id like to know If i can easily remove them by removing the cell/row where they are located, or if i should find the pointer to each item, disconnect them, and then call delete.
The doc says it takes ownership of the widgets
void QTableWidget::setCellWidget(int row, int column, QWidget * widget)
"passing the ownership of the widget to the table."
So it should delete it when needed.
So you should not worry about it.
It also take ownership of any QTableWidgetItem you insert.