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)
标签:pixmap,Qt,pyqt,QtWidgets,tableWidge,label1234,size,hLayout,图片 From: https://www.cnblogs.com/hahaah/p/17396274.html