0
我想添加一個checkbow到QTableWidget中的每一行,不幸的是它似乎只出現在第一行。這裏是我的代碼:Python - 添加複選框到QTableWidget的每一行
data = ['first_row', 'second_row', 'third_row']
nb_row = len(data)
nb_col = 2
qTable = self.dockwidget.tableWidget
qTable.setRowCount(nb_row)
qTable.setColumnCount(nb_col)
chkBoxItem = QTableWidgetItem()
for row in range(nb_row):
for col in [0]:
item = QTableWidgetItem(str(data[row]))
qTable.setItem(row,col,item)
for col in [1]:
chkBoxItem.setFlags(QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled)
chkBoxItem.setCheckState(QtCore.Qt.Unchecked)
qTable.setItem(row,col,chkBoxItem)
我是否缺少明顯的東西?
我查了下帖子也: