KnufflPuffl
25th December 2010, 16:12
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:
void GLOutput::renderPix(){
int heighthelp = this->height();
int helpwidth = this->width();
this->resizeGL(helpwidth,2000); // my window has only a height of 800
QPixmap qp = QPixmap::grabWidget(this,0,0,this->width(),this->height();
qp.save(QFileDialog::getSaveFileName(this, tr("Save File"),"./untitled.png",tr("PNG File (*.png)")),"PNG");
this->resizeGL(helpwidth,heighthelp); // resize it to the original size
}
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
Now I want to output ALL elements to a bitmap file. So far I am using the following code:
void GLOutput::renderPix(){
int heighthelp = this->height();
int helpwidth = this->width();
this->resizeGL(helpwidth,2000); // my window has only a height of 800
QPixmap qp = QPixmap::grabWidget(this,0,0,this->width(),this->height();
qp.save(QFileDialog::getSaveFileName(this, tr("Save File"),"./untitled.png",tr("PNG File (*.png)")),"PNG");
this->resizeGL(helpwidth,heighthelp); // resize it to the original size
}
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