Results 1 to 2 of 2

Thread: QSurface to image

  1. #1
    Join Date
    Feb 2017
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default QSurface to image

    Hello,

    how to export image or take a snapshot of QSurface Widget?

    I'm using QSurface example.

    Kking


    Edit: i have found a solution:

    Qt Code:
    1. QPixmap::grabWindow(graph->winId()).save("img.png");
    To copy to clipboard, switch view to plain text mode 
    Last edited by kkingstoun; 20th February 2017 at 20:01.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QSurface to image

    QPixmap::grabWindow() is an obsolete method which should not be used in new code. It could be removed in a future Qt release.

    If your surface is an OpenGL window, then you can use QOpenGLWindow::grabFrameBuffer() to get a QImage. If it is a QML scene window, use QQuickWindow::grabWindow(). If it is a widget, use QWidget::grab() or QWidget::render().
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 1
    Last Post: 6th September 2016, 16:10
  2. Replies: 15
    Last Post: 24th July 2015, 22:33
  3. Replies: 4
    Last Post: 15th May 2013, 13:58
  4. Replies: 3
    Last Post: 3rd August 2012, 10:35
  5. Replies: 6
    Last Post: 21st September 2009, 10:55

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.