I get the following when I grab a screen shot:
Qt Code:
  1. QPixmap originalPixmap = QPixmap::grabWidget(this);
To copy to clipboard, switch view to plain text mode 

I need to convert originalPixmap to std::vector<unsigned char>.
The problem I face is when I convert this grabbed pixmap to qbytearray or qbuffer it's value becomes NULL! as an example:
Qt Code:
  1. QVariant myPixmap(QPixmap(QPixmap::grabWidget(this)));
  2.  
  3. QByteArray myByteArray = myPixmap.toByteArray() ;
  4.  
  5. qDebug() << myByteArray.size(); // 0 size
To copy to clipboard, switch view to plain text mode 

or
Qt Code:
  1. QPixmap originalPixmap = QPixmap::grabWidget(this);
  2.  
  3. QImage *image = new QImage(originalPixmap.toImage());
  4.  
  5. QByteArray Array;
  6.  
  7. QBuffer buffer(&Array);
  8.  
  9. buffer.open(QIODevice::WriteOnly);
  10.  
  11. image->save(&buffer);
To copy to clipboard, switch view to plain text mode 

again returns null string. am I missing something in the code?