Quote Originally Posted by saman_artorious View Post
I want to get a screen shot of the widget application and then set its raw data buffer to QMeidaPlayer with setMedia(). If anyone tried this before, I would thank if you tell me how to do that:

Qt Code:
  1. QPixmap originalPixmap = QPixmap::grabWidget(this);
  2.  
  3. QImage *image = new QImage(originalPixmap.toImage());
  4.  
  5.  
  6. QBuffer buffer(&ba);
  7.  
  8. buffer.setBuffer(&ba);
  9.  
  10. buffer.open(QIODevice::WriteOnly);
  11.  
  12. image->save(&buffer); // writes image into ba in PNG format
  13.  
  14. image->save("/home/saman/Desktop/myImage", "PNG");
  15.  
  16. mediaPlayer.setMedia(QUrl::fromLocalFile("/home/saman/Desktop/png/images08.jpeg")); //I want this to read from raw data
  17.  
  18. mediaPlayer.play();
To copy to clipboard, switch view to plain text mode 

I note again, what i have done is to receive the image, SAVE it, and then read from it. However, I would like to ask you how to read raw data directly without saving it into media player.

Qt Code:
  1. // saving
  2. counter = 1;
  3. image.save("/home/saman/image", "JPG");
  4. counter = 0;
To copy to clipboard, switch view to plain text mode 

somewhere else, reading
Qt Code:
  1. if(counter == 0)
  2. {
  3. mediaPlayer.setMedia(QUrl::fromLocalFile("/home/saman/image"));
  4. mediaPlayer.play();
  5. }
To copy to clipboard, switch view to plain text mode 
What I did is to use:
Qt Code:
  1. QMediaResource rsrc(QUrl::fromUserInput(image.text()));
  2. QMediaContent ctnt(rsrc);
  3. mediaPlayer.setMedia(ctnt);
  4. mediaPlayer.play();
To copy to clipboard, switch view to plain text mode 
but this, does not show anything. I need help over here, give me advice please.