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));

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

    Can it be done in any way?

  • Lifetime Qt Champion


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

Log in to reply