O
O
Oleg Andreev2020-12-03 19:24:18
Python
Oleg Andreev, 2020-12-03 19:24:18

How to delete row in QtableWidget?

Hello! Guys. Tell me please. I can not achieve the removal of one line. There is a slot.

a = self.ui.raschetList.rowCount()
for row in range(a):
    self.ui.raschetList.removeRow(row)

This removes half of the rows. I am new to QT. what else do I need to pass to the slot to do what I need. Deleted the highlighted line. I also want to understand: what do I need to use to pass to the delete query string in the MySql database. Because, it is necessary that this line be removed from there as well. Already tried a lot, but still does not reach. Thanks in advance. Here is the code from the GUI. To make it clear what rashetList is.
self.raschetList = QtWidgets.QTableWidget(self.groupBox_4)
self.raschetList.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
self.raschetList.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection)
self.raschetList.setObjectName("raschetList")
self.raschetList.setColumnCount(9)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
ZIK1337, 2020-12-03
@RolingHome

when deleting each row, all indexes of subsequent rows are changed, so the part is not deleted

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question