Rajeshwar
Rajeshwar

Reputation: 11681

Obtain a QImage or QPixmap from QStandardItemModel - TableView

I wanted to know if there was a way of obtaining an image displayed on cell on a table in a way like this.Does QStandardItemModel have any methods that could assist ?

QImage p =  MyQStandardItemModelptr->item(row,col)->data();

Any suggestions ?

Upvotes: 0

Views: 424

Answers (1)

vahancho
vahancho

Reputation: 21258

You can try the following call:

QImage p = MyQStandardItemModelptr->item(row,col)->data(Qt::DecorationRole).value<QImage>();

Please note the usage of Qt::DecorationRole.

Upvotes: 2

Related Questions