Search code examples
c++qtqt5qtablewidget

Get rid of cell widget in QTableWidgetItem


As you may know, you can set a widget for a cell in a QTableWidget using setCellWidget:

table->setCellWidget(0, 0, new QProgressBar);

In some circumstances, I just want to get rid of this widget and everything becomes like when there was no cell widget. I tested setting widget to nullptr but It wasn't helpful.
In other words, What is the default widget of a cell in QTableWidget?


Solution

  • You have to use void QTableWidget::removeCellWidget(int row, int column)

    In your case:

    table->removeCellWidget(0, 0);