Can qgraphicsscene be conveted to a pixmap?
-
23-03-2021 - |
Question
I want to convert a QGraphicsScene
to a pixmap, so I can add it to a listwidget as a QGraphicsPixmapItem
. I wonder is it possible?
In another word, what I want to get is just like a thumb
of a QGraphicsScene
.
Solution
Yes, but not directly.
You can convert a QGraphicsView
into a pixmap, using the static function QPixmap::grabWidget()
. Create a graphics view, attach your scene to the view, and then convert the widget.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow