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 to insert a picture in the merged cell(2 lines) of QTablewidget ?
Forum Updated to NodeBB v4.3 + New Features

How to insert a picture in the merged cell(2 lines) of QTablewidget ?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 736 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.
  • J Offline
    J Offline
    JesseBlack
    wrote on last edited by
    #1

    I insert a picture in the merged cell(2 lines) of QTablewidget,but the picture can only display height of one line and becomes very narrow.How to solve it?
    my code:
    tableWidget1->setItem(3,3,newQTableWidgetItem(QIcon("image2/vm.png"),tr("Ab")));
    tableWidget1->resizeColumnToContents(3);
    tableWidget1->resizeRowToContents(3);

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JesseBlack
      wrote on last edited by
      #2

      I have made it without using delegate!
      the code:

      tableWidget1->setItem(3,3,new QTableWidgetItem(tr("")));

      QPixmap pix1("image2/vm1.png");
      QBrush brush1(pix1);
      tableWidget1->item(3,3)->setBackground(brush1);

      tableWidget1->resizeColumnToContents(3);
      tableWidget1->resizeRowToContents(3);

      1 Reply Last reply
      0

      • Login

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