PDA

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



JesseBlack
6th March 2014, 12:37
I insert a picture in the merged cell(2 lines) of QTablewidget,but the pictures can only display height of one line and becomes very narrow.How to solve it? I write the code in QT with C#.
my code:

tableWidget1->setItem(3,3,newQTableWidgetItem(QIcon("image2/vm.png"),tr("Ab")));
tableWidget1->resizeColumnToContents(3);
tableWidget1->resizeRowToContents(3);

JesseBlack
15th March 2014, 12:15
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);