void changeWidth() {
    Integer newWidth =
        QInputDialog.getInteger(
            this,
            tr("Change table width"),
            tr("Input the number of columns required (1-20):"),
            tableWidget.columnCount(),
            1,
            20,
            1);

    if (newWidth != null) tableWidget.setColumnCount(newWidth);
  }
  void setupTableItems() {
    // ! [1]
    tableWidget.setRowCount(10);
    tableWidget.setColumnCount(5);
    // ! [1]

    for (int row = 0; row < tableWidget.rowCount(); ++row) {
      for (int column = 0; column < tableWidget.columnCount(); ++column) {
        // ! [2]
        QTableWidgetItem newItem = new QTableWidgetItem("" + (row + 1) + ", " + (column + 1));
        tableWidget.setItem(row, column, newItem);
        // ! [2]
      }
    }
  }