문제

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.

도움이 되었습니까?

해결책

QListWidgetItem *item = new QListWidgetItem("something", listWidget);
itemitem->setData(Qt::DecorationRole, QPixmap::fromImage(image));
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top