Results 1 to 2 of 2

Thread: How to render context of QGLWidget, outside of the window

  1. #1
    Join Date
    Sep 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How to render context of QGLWidget, outside of the window

    Hey. I have written a QT application, which draws a lot of elments inside it. So I have made it possible to scroll inside this window.

    Now I want to output ALL elements to a bitmap file. So far I am using the following code:

    Qt Code:
    1. void GLOutput::renderPix(){
    2.  
    3. int heighthelp = this->height();
    4. int helpwidth = this->width();
    5.  
    6. this->resizeGL(helpwidth,2000); // my window has only a height of 800
    7.  
    8. QPixmap qp = QPixmap::grabWidget(this,0,0,this->width(),this->height();
    9. qp.save(QFileDialog::getSaveFileName(this, tr("Save File"),"./untitled.png",tr("PNG File (*.png)")),"PNG");
    10.  
    11. this->resizeGL(helpwidth,heighthelp); // resize it to the original size
    12. }
    To copy to clipboard, switch view to plain text mode 

    The problem is that this code works fine for the actual context which is viewable for the user at the moment, but I need something that renders all elements inside the Widget. So my idea was simply to make the GLWidget bigger, before rendering, but this has no effect at all.
    I think the problem is that all pixels which are not directly shown in the window are invalid.

    Any ideas are very appreciated. I simply don't know how to define the renderArea I want to grab.

    thx in advance

  2. #2
    Join Date
    Mar 2008
    Location
    Marslev, Denmark
    Posts
    31
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: How to render context of QGLWidget, outside of the window

    You probably have to use QGLFrameBufferObject for this.
    Bo Thorsen, Viking Software
    Qt applications on Linux and Windows

Similar Threads

  1. QGLWidget and QThread, how to render in separate thread?
    By DIMEDROLL in forum Qt Programming
    Replies: 3
    Last Post: 2nd December 2010, 19:56
  2. Replies: 8
    Last Post: 9th November 2010, 21:11
  3. Render QWidget within QGLWidget
    By crazymonkey in forum Newbie
    Replies: 29
    Last Post: 26th September 2010, 13:54
  4. Replies: 1
    Last Post: 7th May 2010, 17:20
  5. QGLWidget Render Text in the foreground
    By arpspatel in forum Qt Programming
    Replies: 1
    Last Post: 11th April 2010, 11:35

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.