Use functions provided by QT to implement screenshots:
Qpixmap: grabwindow (WID window, int x = 0, int y = 0, int width =-1, int Height =-1)
Window: the ID of the window.
X and Y: the coordinates of the captured Screen
Width: the width of the captured screen.-1 indicates the current window width.
Height: the height of the captured screen.-1 indicates the height of the current window.
Example:
Qstring filename;
Qpixmap pixmap;
Qpixmap pix;
// Pix = pixmap. grabwindow (this-> winid (), 0, 0,-1,-1); // retrieve the current window
PIX = pixmap. grabwindow (qapplication: desktop ()-> winid (); // retrieve the entire screen window
// Name before that
Filename = qdatetime: currentdatetime (). tostring ("yyyy-mm-dd hh-mm-SS") + ". BMP ";
If (pix. isnull ()
{< br> qmessagebox: Information (this, "error", "Grab screen failed! ", Qmessagebox: OK);
}< br> else
{< br> If (! PIX. save (".. /screen/"+ filename," BMP ")
{< br> qmessagebox: Information (this," right "," Save error! ", Qmessagebox: OK);
}< br> else
{< br> qmessagebox: Information (this," Grab "," Save successful! ", Qmessagebox: OK);
}< BR >}