How to Take Screenshots Using Qt

Posted on Posted in Qt Tutorials, Tutorials

Qt allows you to easily grab an screenshot and save it using grabWindow function implemented in QScreen. Here is how you can use it:

First of all decide on which part of the size and location of the screenshot you want to take. This means you have to create a QRect which has left, right, width and height values. Like this:

QRect crop_rect(x, y, w, h);

Next you can call grabWindow by providing this crop_rect to it to take an screenshot of any part of the screen.

QImage desk = qApp->screens().at(0)->grabWindow(

Please note that you can take an screenshot of the whole screen like this:

QImage desk = qApp->screens().at(0)->grabWindow(

Leave a Reply

Your email address will not be published. Required fields are marked *