Question

I have a QListWidget instance in the middle of my application. I want to populate it with some dynamically created QImage.

After reading the manual I have understand that i have to pass through a QIcon object. But.. How can I create a QIcon from a QImage?

I've seen an example, for instance

/Developer/Examples/Qt/itemviews/stardelegate

but it is not very useful, and around the internet I haven't found any suitable snippet.

Was it helpful?

Solution

QListWidgetItem *item = new QListWidgetItem("something", listWidget);
itemitem->setData(Qt::DecorationRole, QPixmap::fromImage(image));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top