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());
  2.  
  3. ui.myLabel->setPixmap(pix); //This is fine. Displays the Screenshot
  4. ui.myLabel->setScaledContents(true);
  5.  
  6. QByteArray bArray;
  7. QBuffer buffer(&bArray);
  8. buffer.open(QIODevice::WriteOnly);
  9.  
  10. qDebug()<<"before";
  11. pix.save(&buffer); //Gives SEGV Error
  12. qDebug()<<"after";
  13.  
  14. buffer.close();
To copy to clipboard, switch view to plain text mode 


Not able to figure out what the problem is.