Reputation: 139
I'm using Qt-5.2 and Win7.
The application uses two monitors and I would like to take a screenshot that contains both screens. QGuiApplication::screens() gives back the list of the two QScreen objects, and when I took screenshot of the primary screen, then it was OK. But now I need a screenshot of both, so QDesktopWidget seemed to be a good choice. The QDesktopWidget object is a virtual one, so it handles the two screens in a virtual desktop.
When I use this, the the pixmap is properly generated.
QPixmap pm = some_widget->grab();
But when I try this with the desktop widget, I get only a grey image.
QPixmap pm = QApplication::desktop()->grab();
Any idea? Thanks!
Upvotes: 1
Views: 1007
Reputation: 139
I did not intend to use this, because it is obsolete, but I managed to do what I want only in this way:
QDesktopWidget* dw = QApplication::desktop()
QPixmap pixmap = QPixmap::grabWindow( dw->winId(), 0, 0, dw->width(), dw->height() );
Upvotes: 2