technoViking
25th October 2010, 15:06
Hi,
I have several widgets in a graphics scene. I want to take a image copy of 1 of the widgets.
I attempted the following:
QPixmap screenshot;
screenshot = QPixmap::grabWidget(theWidget,theWidget.rect());
screenshot.save("test.png","PNG");
THis will save the widget but the widget is stripped of EVERYHTING. Basically you don't see the background image on the widget, you don't see any alpha settings I set, you simply see an outline of the widget and some text.
I also tried:
QImage image(300,300,QImage::Format_RGB32);
QPainter painter(&image);
TheGraphicsView->render(&painter);
image.save("test.png","PNG");
This will give me the exact same result as above.
Lastly I tried:
screenshot = QPixmap::grabWindow(QApplication::desktop()->winId());
This will capture the whole screen which is not what I wanted. This will though show everyhting fully rendered.
Any ideas how I can capture just 1 WIDGET in the graphics view fully rendered?
Thanks
I have several widgets in a graphics scene. I want to take a image copy of 1 of the widgets.
I attempted the following:
QPixmap screenshot;
screenshot = QPixmap::grabWidget(theWidget,theWidget.rect());
screenshot.save("test.png","PNG");
THis will save the widget but the widget is stripped of EVERYHTING. Basically you don't see the background image on the widget, you don't see any alpha settings I set, you simply see an outline of the widget and some text.
I also tried:
QImage image(300,300,QImage::Format_RGB32);
QPainter painter(&image);
TheGraphicsView->render(&painter);
image.save("test.png","PNG");
This will give me the exact same result as above.
Lastly I tried:
screenshot = QPixmap::grabWindow(QApplication::desktop()->winId());
This will capture the whole screen which is not what I wanted. This will though show everyhting fully rendered.
Any ideas how I can capture just 1 WIDGET in the graphics view fully rendered?
Thanks