QTableWidget中插入按钮
button = get_button()
tableWidget.setCellWidget(0, 2, button)
def get_button():
Btn = QPushButton("测试")
Btn.setCheckable(True)
Btn.setStyleSheet(''' text-align : center;
margin:3px;
background-color : NavajoWhite;
font : 13px ''')
return Btn
QTableWidget中插入checkbox
list = get_checkbox()
widget = list[0]
checkbox = list[1]
tableWidget.setCellWidget(1, 2, widget)
def get_checkbox():
checkbox = QCheckBox()
hLayout = QHBoxLayout()
hLayout .addWidget(checkbox)
hLayout .setAlignment(checkbox, Qt.AlignCenter)
widget = QWidget()
widget .setLayout(hLayout)
return widget, checkbox
QTableWidget中获取相应按钮的位置
row = tableWidget.indexAt(button_list[i].pos()).row()