Z
Z
Zakhar2021-06-08 14:09:42
Photo
Zakhar, 2021-06-08 14:09:42

How to resize a photo in a PyQt5 cell?

I added a photo to the table, but it is very large. How to make it even the size of a cell.
Tried setGeometry, QSize - didn't help

def addItemPhoto():
    try:
        for i in range(len(get_tovaru()['names'])):
            rowPosition = ui.table_product.rowCount()
            ui.table_product.insertRow(rowPosition)

            pic = QPixmap('F:/ProSupApp/2404482952_sapbord-red-paddle.jpg')
            label = QtWidgets.QLabel()
            label.setAlignment(QtCore.Qt.AlignCenter)
            label.setPixmap(pic)
            label.resize(0, 0)

            ui.table_product.setCellWidget(i, 1, label)


            #ui.table_product.setItem(i, 1, QTableWidgetItem(get_tovaru()['photo'][i]))
            print((get_tovaru()['photo']))
    except Exception as e:
        logging.exception(e)
        print(get_tovaru()['photo'][0])

60bf4fe888eb7697564303.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question