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-

Qt Code:
  1. QPixmap pix = QPixmap::grabWindow(QApplication::desktop()->winId());
  3. ui.myLabel->setPixmap(pix); //This is fine. Displays the Screenshot
  4. ui.myLabel->setScaledContents(true);
  6. QByteArray bArray;
  7. QBuffer buffer(&bArray);
  8. buffer.open(QIODevice::WriteOnly);
  10. qDebug()<<"before";
  11. pix.save(&buffer); //Gives SEGV Error
  12. qDebug()<<"after";
  14. buffer.close();
To copy to clipboard, switch view to plain text mode 

Not able to figure out what the problem is.