I have the following problem: I try to delete a selected row of a TableWidget but it does not work. This is the function I occupy:
self.check.clicked.connect(lambda:self.tabla.selectedItems().clear())
And this is the complete code:
from PyQt5.QtWidgets import *
from PyQt5 import uic
class Principal(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
uic.loadUi("columna.ui",self)
self.tabla.insertRow(self.tabla.rowCount())
self.tabla.setItem(self.tabla.rowCount()-1,2,QTableWidgetItem("sdsd"))
self.tabla.setItem(self.tabla.rowCount()-1,1,QTableWidgetItem("sdsd"))
self.tabla.insertRow(self.tabla.rowCount())
self.tabla.setItem(self.tabla.rowCount()-1,1,QTableWidgetItem("sdsd"))
self.boton.clicked.connect(lambda:self.tabla.setShowGrid(False)) #Limpiar sin dejar la rejilla en la tabla
self.check.clicked.connect(lambda:self.tabla.selectedItems().clear()) #Función para eliminar solo una row
app = QApplication([])
p = Principal()
p.show()
app.exec_()