Qt Screenshot example not compiling With Qt5.x ?
-
wrote on 8 Jul 2020, 14:50 last edited by
Re: Qt Screenshot example not compiling With Qt5.x ?
I'd just want to add that following code (very simple) which works perfectly
to achieve full 1024 x 600 pixels screenshot of physical display on my target:QRect crop_rect(/*x*/0, /*y*/0, /*w*/1024, /*h*/600); QDesktopWidget *pDesk = QApplication::desktop(); int id = pDesk->screenNumber(); QImage desk = qApp->screens().at(0)->grabWindow( id, crop_rect.left(), crop_rect.top(), crop_rect.width(), crop_rect.height()).toImage(); desk.save(QString("screen_%1x%2.png") .arg(crop_rect.width()) .arg(crop_rect.height()) /*,0,-1*/);
--> this will save 1024 x 600 pixels screenshot as "screen_1024x600.png" image file that can be displayed by any image viewer application...
;^)
Alain-Pierre (apclinux)
-
Re: Qt Screenshot example not compiling With Qt5.x ?
I'd just want to add that following code (very simple) which works perfectly
to achieve full 1024 x 600 pixels screenshot of physical display on my target:QRect crop_rect(/*x*/0, /*y*/0, /*w*/1024, /*h*/600); QDesktopWidget *pDesk = QApplication::desktop(); int id = pDesk->screenNumber(); QImage desk = qApp->screens().at(0)->grabWindow( id, crop_rect.left(), crop_rect.top(), crop_rect.width(), crop_rect.height()).toImage(); desk.save(QString("screen_%1x%2.png") .arg(crop_rect.width()) .arg(crop_rect.height()) /*,0,-1*/);
--> this will save 1024 x 600 pixels screenshot as "screen_1024x600.png" image file that can be displayed by any image viewer application...
;^)
Alain-Pierre (apclinux)
@apclinux And what is the problem?
1/3