Hussain Dholkawala Hussain Dholkawala - 4 months ago 36
Python Question

Get table row values based on whether QCheckbox is checked

Code removed from the question


The error happens because you haven't set any cell widgets, and so cellWidget() will always return None. However, this is irrelevant, since you actually need to query the checked-state of the table-widget items (which is what you have made checkable).

Your code should probably look more like this:

    def ButtonClicked(self):
        checked_listV5 = []
        for i in range(self.tableV5.rowCount()):    
            if self.tableV5.item(i, 0).checkState() == QtCore.Qt.Checked:
                checked_listV5.append(self.tableV5.item(i, 1).text())