How to get and save screenshot in Qt

We can to get screen of device or screen of running app.

Code for get screen of device and save in .png format:

    QPixmap p;
    QScreen *screen = QGuiApplication::primaryScreen();
    if (screen)
       p = screen->grabWindow(0);//(0, 0, 0, 100, 20);//WinId, X, Y, width, height
    QImage qImage = p.toImage();"screen.png");

Code for get screen of running app and save in .png format:

    QPixmap p = this->grab();
    QImage qImage = p.toImage();"screen.png");


You May Also Like

About the Author: WebSofter

Web - технологии

1 Звезда2 Звезды3 Звезды4 Звезды5 Звезд (Пока оценок нет)

Отправить ответ

Notify of