Issue
I'm working with pyqt, and I'm trying to delete a button every time the layout of the model change.
Sometimes it works but most of time the app closes with : Segmentation fault (core dumped)
I don't get the issue, okay a memory fault but why ?
self.tasktablemodel.layoutChanged.connect(self.setupTableTask)
def setupTableTask(self):
for i in range(0, self.tasktablemodel.rowCount1()):
progress = QProgressBar()
progress.setValue(self.tasktablemodel._data[i][3])
self.TaskTable.setIndexWidget(self.tasktablemodel.index(i,3), progress )
if self.tasktablemodel._data[i][8] == 0 and self.tasktablemodel._data[i][9] == 0:
delete = QPushButton()
delete.clicked.connect(self.Kill_Task_clicked)
self.tasktablemodel.layoutChanged.connect(delete.deleteLater)
delete.setText("")
delete.setIcon(QtGui.QIcon('src/ui/delete-icon.png'))
self.TaskTable.setIndexWidget(self.tasktablemodel.index(i,0), delete )
self.TaskTable.setColumnHidden(8, True)
self.TaskTable.setColumnHidden(9, True)
self.TaskTable.resizeColumnsToContents()
self.TaskTable.scrollToBottom()
return
Solution
To delete an object from a QTableView in python,
you just need to setIndexWidget
to None
.
self.TaskTable.setIndexWidget(self.tasktablemodel.index(i,0), None )
other answer there : How to remove widget from QAbstractItemView
Answered By - jgcb00
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.