sattu
11th July 2017, 15:54
Hello all,
I am trying to capture a screenshot of my Application in a QPixmap and then save it to a QIODevice. But it's giving segmentation fault.
Not able to figure out why.
Here's the code-
QPixmap pix = QPixmap::grabWindow(QApplication::desktop()->winId());
ui.myLabel->setPixmap(pix); //This is fine. Displays the Screenshot
ui.myLabel->setScaledContents(true);
QByteArray bArray;
QBuffer buffer(&bArray);
buffer.open(QIODevice::WriteOnly);
qDebug()<<"before";
pix.save(&buffer); //Gives SEGV Error
qDebug()<<"after";
buffer.close();
Not able to figure out what the problem is. :(
I am trying to capture a screenshot of my Application in a QPixmap and then save it to a QIODevice. But it's giving segmentation fault.
Not able to figure out why.
Here's the code-
QPixmap pix = QPixmap::grabWindow(QApplication::desktop()->winId());
ui.myLabel->setPixmap(pix); //This is fine. Displays the Screenshot
ui.myLabel->setScaledContents(true);
QByteArray bArray;
QBuffer buffer(&bArray);
buffer.open(QIODevice::WriteOnly);
qDebug()<<"before";
pix.save(&buffer); //Gives SEGV Error
qDebug()<<"after";
buffer.close();
Not able to figure out what the problem is. :(