I Have a qtableWidget and must delete all existing rows when click a button, I am trying as follows, but it only deletes one row at a time

Qt Code:
  1. for (int i = 0; i < ui.tableWidget->rowCount(); i++)
  2. ui.tableWidget->removeRow(i);
To copy to clipboard, switch view to plain text mode