Unsolved Is there any easy way to generate a bitmap of an QWindow?
-
I am recently use QtOpenGL and I imitate the example of "Qt OpenGL Window" to subclass the QWindow class to draw my polygon.One step in my task is to output the content in bitmap way of the window.So,is there any easy way to output the content in QWindow?Before I use the OpenGL "glGetRead" function to get the pixel value to solve this question .
-
I would try to use the grabWindow function of the window's QScreen. Something like the following:
QScreen *screen=myWindow->screen(); QPixmap pixmap=screen->grabWindow(myWindow->winId());
(Never tested it, though.)
-Michael.
-
Much simpler, this example will save a png to disk. If you need to return the pixmap instead that's easy to do:
QPixmap::grabWindow(QApplication::desktop()->winId()).save(QString(location+".png"));
-
@m.sue Thx man,I will try it later~
-
@Swerved Thx man~