Динамически добавлять колонки в таблицу PySide2
У меня есть таблица,в которой две строки.На первой строке изображение, на второй строке кнопка. Количество колонок зависит от количества картинок. Как добавлять колонки динамически? Не могу сообразить
UI.py
self.table_images = QtWidgets.QTableWidget()
header_class = self.table_images.horizontalHeader()
header_class.hide()
vert_class=self.table_images.verticalHeader()
vert_class.hide()
self.table_images.setRowCount(2)
self.table_images.setRowHeight(0,280)
self.table_images.setRowHeight(1, 20)
self.table_images.setFixedWidth(1400)
self.table_images.setFixedHeight(320)
app.py
for i,pic in enumerate(list_of_imgs):
resize_pic=resize(pic,(280,280))
success, ei = cv2.imencode('.png', resize_pic)
img_png = ei.tobytes()
img_rgb = QtGui.QImage.fromData(img_png, 'PNG')
pixmap = QtGui.QPixmap.fromImage(img_rgb)
label_im = QtWidgets.QLabel()
label_im.setPixmap(pixmap)
table_imgs.setCellWidget(0, i, label_im)
button_color = QtWidgets.QPushButton()
#button_color.clicked.connect(lambda: change_color(table_classes, file))
button_color.setFixedWidth(50)
button_color.setStyleSheet(f"background-color:red;")
table_imgs.setCellWidget(1, i, button_color)