PyQt5 - QPushButton to add row to a QTableView
-
wrote on 14 Feb 2021, 08:02 last edited by
-
wrote on 14 Feb 2021, 08:21 last edited by
You can implement 'add row to QTableView' action for button in that way:
from PyQt5.QtGui import QStandardItemModel, QStandardItem ... table = QTableView(...) table.setModel(QStandardtemModel()) addRowButton = QPushButton('Add row', ...) addRowButton.clicked.connect(lambda: table.model().insertRow(0, [QStandardItem('1'), QStandardItem('example'), ...])
1/2