I am writing a screenshotting app (a bit like puush) using Qt 4.8, and I am having troubles with multiple screens setups, especially when the main monitor (with coordinates
You can access each screen information inside the QDesktopWidget
widget you are using and compute the overall rectangle for the snapshot.
int screens = desktop->screenCount();
QRect wholeDisplayGeometry;
for (int i = 0; i < screens; ++i) {
QRect screenRect = desktop->screen(i)->geometry();
wholeDisplayGeometry = wholeDisplayGeometry.united(screenRect); //union
}
Now you can take the shot using the rectangle information:
QPixmap shot = QPixmap::grabWindow (
desktop->winId (),
wholeDisplayGeometry.x(),
wholeDisplayGeometry.y(),
wholeDisplayGeometry.width(),
wholeDisplayGeometry.height()
);