xleniz
20th March 2013, 22:14
Hi, im on Linux, and Im trying to save a screenshot.
I read that QPixmap::grabWindow() is deprecated, and that I should use QScreen::grabWindow() instead.
So I did.
The problem is: The image is not being saved right, and does not show up the correct part of screen (only 4 parts of screen, upside down and in all kind of ways).
This ma code.
void Widget::on_pushButton_clicked()
{
QScreen *QSCREEN = QGuiApplication::primaryScreen();
QPixmap qpix = QSCREEN->grabWindow(this->winId(), 0, 0, QApplication::desktop()->width(),
QApplication::desktop()->height());
qpix.save("/home/marcus/Bilder/Hello.png");
}
I read that QPixmap::grabWindow() is deprecated, and that I should use QScreen::grabWindow() instead.
So I did.
The problem is: The image is not being saved right, and does not show up the correct part of screen (only 4 parts of screen, upside down and in all kind of ways).
This ma code.
void Widget::on_pushButton_clicked()
{
QScreen *QSCREEN = QGuiApplication::primaryScreen();
QPixmap qpix = QSCREEN->grabWindow(this->winId(), 0, 0, QApplication::desktop()->width(),
QApplication::desktop()->height());
qpix.save("/home/marcus/Bilder/Hello.png");
}