Results 1 to 2 of 2

Thread: QPixmap::grabWidget and QPixmap::grabWindow with QGLWidget-derived object

  1. #1

    Default QPixmap::grabWidget and QPixmap::grabWindow with QGLWidget-derived object

    Hi,

    I am using Qt 4.3.4. I am trying to get a screen capture of a QGLWidget-derived object saved to a file. I followed the Qt Screenshot example. However, when I examine the image that I get from the following code:

    Qt Code:
    1. QPixmap originalPixmap = QPixmap::grabWidget(qglThing);
    2. originalPixmap.save("C:\\example.png", "png");
    To copy to clipboard, switch view to plain text mode 

    the image is simply a black box (which would be the bottom layer in my scene graph). Clearly, this doesn't behave the same as Windows alt-print screen mnemonic.

    Is there something special that I have to do to grab the QGLWidget-derived image? Is this a bug? Or would I have to use an entirely different method?

    Thanks,
    David
    Last edited by jpn; 20th August 2008 at 21:36. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QPixmap::grabWidget and QPixmap::grabWindow with QGLWidget-derived object

    I can imagine grabbing GL widget will not work. You might try grabbing the desktop widget and cutting out the interesting part. Otherwise you might need to use QGLFrameBufferObject to render the widget to the buffer and then convert it to an image.

  3. The following user says thank you to wysota for this useful post:

    y.shan (21st January 2011)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.