jeudi 12 août 2021

Python Can I put two check boxes in one row from the Qtablewidget?

I want to put two check boxes in one row from Qtablewidget, but one combo box disappears and only one is put in.

This is code..

    flen = self.subtypeMap.shape[0]
    self.checkboxlist = []
    self.checkboxlist2 = []
    self.listWidget.setRowCount(flen)
    self.listWidget.setColumnCount(3)
    self.header_labels = ['1','test', '2']
    for i in range(self.subtypeMap.shape[0]):
        Subtype_count = int(self.subtypeMap.loc[:,'Subtype_count'].iloc[i])
        self.listWidget.setItem(i, 0, QTableWidgetItem(str(self.subtypeMap.loc[:,'Subtype_name'].iloc[i])+ ' (' + str(Subtype_count) + ')'))
        checkbox = QCheckBox()
        checkbox.setChecked(True)
        self.checkboxlist.append(checkbox)
        self.listWidget.setCellWidget(i, 1, self.checkboxlist[i])
        checkbox2 = QCheckBox()
        checkbox2.setChecked(True)
        self.checkboxlist2.append(checkbox)
        self.listWidget.setCellWidget(i, 2, self.checkboxlist2[i])
        self.listWidget.setHorizontalHeaderLabels(self.header_labels)
    self.table_sample.resizeColumnsToContents()  # width of columns

Do you see any problems with this for loop?

enter image description here




Aucun commentaire:

Enregistrer un commentaire