I'm working on to an application, and I want to used QPixmap::grabWidget function to save a pixmap of my widget. The build is well, but I have an error when I run the application:
@ASSERT failure in QGLPainter: "begin() has not been called or it failed", file painting/qglpainter.cpp, line 770@
This is a part of my code:
@ QPixmap originalPixmap0 = QPixmap();
// originalPixmap = QPixmap::grabWindow(My_Widget->winId());
originalPixmap0 = QPixmap::grabWidget(My_Widget);@
If I use the grabWindows, it's work well. But I want to use grabWidget to hide my widget and still have it on my Pixmap.
Does anyone can help me to found where is came from?
I'm not sure gradWidget works with an openGL widget at all...
Thanks for the reply.
Thereby, from what you said, I can not use grabWidget, and I have to used grabWindow. But, it is not possible to get a pixmap from an hidden Qwidget with grabWindow, is it?
What I want to do is some like:
QPixmap originalPixmap0 = QPixmap();
originalPixmap = QPixmap::grabWindow(My_Widget->winId());@
Using that way, I want to have a Pixmap of my widget, without displayed it on the screen. I have tried this, and the saved QPixmap was a screenshoot of my desktop, not an image of my widget.
I said that I doubt that it works, not that I'm sure it does not work. It would the first thing I'd look into to find the cause of your issue.
I don't know if there are ways to render openGL into a pixmap without it being displayed on screen.
Thanks for your answer. I gonna have a look on this. And I hope to find a way to do this.