我是 qt 的新手,根据我的研究,我可以使用缩放函数更改像素图/图像的大小。但是当我运行程序时,图像大小仍然相同。这是代码。
QStringList headers;
QString headerValues="header1,header2";
headers=headerValues.split(",");
ui->tableWidget_2->setColumnCount(2);
ui->tableWidget_2->setHorizontalHeaderLabels(headers);
QStringList verticalHeaders;
QString verticalHeaderValues="vertical1,vertical2";
verticalHeaders=verticalHeaderValues.split(",");
ui->tableWidget_2->setRowCount(1);
ui->tableWidget_2->setVerticalHeaderLabels(verticalHeaders );
ui->tableWidget_2->horizontalHeader()->setDefaultSectionSize(150);
ui->tableWidget_2->verticalHeader()->setDefaultSectionSize(150);
ui->tableWidget_2->horizontalHeader()->setResizeMode(QHeaderView::Fixed);
ui->tableWidget_2->verticalHeader()->setResizeMode(QHeaderView::Fixed);
QString filename="/home/marcvincento/Desktop/Private/Projects/fixButtons/Printer.png";
QPixmap pic(filename);
pic.scaled ( 20, 20, Qt::IgnoreAspectRatio, Qt::FastTransformation );
QBrush brush(pic);
QTableWidgetItem* item=new QTableWidgetItem();
item->setBackground(brush);
item->setText("ADD 5,1");
ui->tableWidget_2->setItem(0,0,item);