Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How does a Qtablewidget display images ?
Forum Updated to NodeBB v4.3 + New Features

How does a Qtablewidget display images ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 721 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zj.liu
    wrote on 1 Sept 2020, 04:06 last edited by
    #1

    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?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 1 Sept 2020, 16:32 last edited by
      #2

      Hi,

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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2

      2/2

      1 Sept 2020, 16:32

      • Login

      • Login or register to search.
      2 out of 2
      • First post
        2/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved