Answer the question
In order to leave comments, you need to log in
How to delete a qtablewidget row using a button on that row?
There is a program in pyqt5.
There is such a nice class, it is called from somewhere in the bowels of the program.
import PyQt5.QtWidgets as qtw
import dialog
class blablabla(qtw.QDialog, dialog.Ui_dialog):# dialog.Ui_dialog тупа описание интерфайса диалога
...
def add(self):
self.table.insertRow(self.table.rowCount())
self.table.setItem(self.table.rowCount()-1, 0, qtw.QTableWidgetItem("Put smth here"))
self.table.setItem(self.table.rowCount()-1, 1, qtw.QTableWidgetItem("Put smth here"))
...
btn = qtw.QPushButton("Remove")
self.table.setCellWidget(self.table.rowCount()-1, self.table.columnCount()-1, btn)
Answer the question
In order to leave comments, you need to log in
Fuck, I banned myself from Google along the way.
In short, here is the solution and the link where I found it
import PyQt5.QtWidgets as qtw
import dialog
class blablabla(qtw.QDialog, dialog.Ui_dialog):# dialog.Ui_dialog тупа описание интерфайса диалога
...
def add(self):
self.table.insertRow(self.table.rowCount())
self.table.setItem(self.table.rowCount()-1, 0, qtw.QTableWidgetItem("Put smth here"))
self.table.setItem(self.table.rowCount()-1, 1, qtw.QTableWidgetItem("Put smth here"))
...
btn = qtw.QPushButton("Remove")
self.table.setCellWidget(self.table.rowCount()-1, self.table.columnCount()-1, btn)
btn.clicked.connect(self.removecurrentrow)
def removecurrentrow(self):
button = self.sender()
if button:
row = self.table.indexAt(button.pos()).row()
self.table.removeRow(row)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question