Pregunta

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.

¿Fue útil?

Solución

QListWidgetItem *item = new QListWidgetItem("something", listWidget);
itemitem->setData(Qt::DecorationRole, QPixmap::fromImage(image));
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top