PDA

View Full Version : Display of a widget into an image file?



feraudyh
16th April 2017, 19:00
I want to take advantage of features such as layouts, size policies and so on to do some drawing based on an assembly of nested widgets. Instead of displaying on the screen
I'd like to display into an image file or a QImage object, so I can save it as a file in a variety of formats. Is there any way of doing this?

wysota
16th April 2017, 21:32
Yes, you can use QWidget::render() to save a snapshot of a widget as an image however usually this is not a recommended approach. It might be easier for you to use what QGraphicsView framework offers (you can render a scene into an image using QGraphicsScene::render()).