Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
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 .
m.sue last edited by
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.)
Swerved last edited by
Much simpler, this example will save a png to disk. If you need to return the pixmap instead that's easy to do:
@m.sue Thx man,I will try it later~
@Swerved Thx man~