Get image from QTableWidgetItem
-
I set table widget item
QTableWidgetItem *thumbnail = new QTableWidgetItem;
//
thumbnail->setData(Qt::DecorationRole, ( QPixmap( url.path() ) ).scaled(144, 168));
ui->tableWidget->setItem(row, 1, thumbnail);How I can get image from this cell?
-
Hi, you mean the image is not visible? Maybe try instead:
QTableWidgetItem *thumbnail = new QTableWidgetItem( QIcon( QPixmap( url.path() ) .scaled(144, 168)),""); // ui->tableWidget->setItem(row, 1, thumbnail);
-
No it is visible and i want to get it and save to file
-
Ok I see, guessing but it should be something like:
QPixmap m = ui->tablewidget->item(row,1)->data(Qt::DecorationRole);
-
@hskoglund said:
QPixmap m = ui->tablewidget->item(row,1)->data(Qt::DecorationRole);
no viable conversion from 'QVariant' to 'QPixmap'
-
Sorry :-) try this:
QPixmap m = ui->tablewidget->item(row,1)->data(Qt::DecorationRole).value<QPixmap>();
-
Thank you very much!!!! It is work!