Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How does a Qtablewidget display images ?



  • I want to add an image in the Qtablewidget that fills the entire cell and changes along with the height and column width:

        item = new QTableWidgetItem();
        item->setData(Qt::DecorationRole, QPixmap(p_info->mSnap_path+"/"+p_info->mSnap_name).scaled(80,80,Qt::IgnoreAspectRatio));
        this->compare_rec->setItem(row,0,item);
    

    The image is displayed, but when I change the column width or row height, the image does not fill the entire cell:

    497e1f5b-5ba9-4b8c-a5fd-37a1a0c625c6-image.png
    Can it be done in any way?


  • Lifetime Qt Champion

    Hi,

    You would need to implement a custom QStyledItemDelegate to scale the image.


Log in to reply