PyQt5 QTableWidget中设置行为可选状态,并居中显示

admin 12天前 6

check = QCheckBox()

check.setCheckState(QtCore.Qt.Unchecked)  # 把checkBox设为未选中状态

hbox = QtWidgets.QHBoxLayout()

hbox.setAlignment(Qt.AlignCenter)

hbox.addWidget(check)

hbox.setContentsMargins(0, 0, 0, 0)

wid_chk = QWidget()

wid_chk.setLayout(hbox)

# check = QtWidgets.QTableWidgetItem()

# check.setCheckState(QtCore.Qt.Unchecked)  # 把checkBox设为未选中状态

self.__ui.tableWidget.setCellWidget(x, y, wid_chk)  # 在(x,y)添加checkBox


最新回复 (0)
返回
发新帖