pyqt tableWidge显示图片
tableWidge中插入控件并居中
label1234 = QtWidgets.QLabel()
pixmap = QtGui.QPixmap("0.jpg")
pixmap = pixmap.scaled(
QtCore.QSize(100, 100),
QtCore.Qt.KeepAspectRatio,
QtCore.Qt.SmoothTransformation,
)
size = pixmap.size()
label1234.setPixmap(pixmap)
it2 = QtWidgets.QTableWidgetItem()
it2.setSizeHint(size)
label1234.setFixedSize(size)
hLayout = QtWidgets.QHBoxLayout()
hLayout.addWidget(label1234)
hLayout.setAlignment(label1234, Qt.AlignCenter)
widget1234 = QtWidgets.QWidget()
widget1234.setLayout(hLayout)
self.tableWidget.setCellWidget(1, 4, widget1234)