[Qt-interest] QGLWidget

Nathan Carter ncarter at bentley.edu
Tue May 26 22:46:19 CEST 2009


I have an application I've written and am compiling in Qt 4.5.  It  
uses a QGLWidget subclass I've written.  I create one instance of the  
subclass and keep it offscreen, so that when previews of things need  
to be generated, that object can be configured/populated with the  
stuff to render, and then I call QGLWidget::renderPixmap() on it,  
returning a pixmap.

The problem is that on Mac and Windows this works great, but on Linux  
the pixmaps returned are full of garbage data.  This is not a memory  
issue (i.e., accessing freed memory) as far as I know, because my code  
looks like this:

	// quickviewer is the instance
	quickviewer->resize( w, h ); // desired width and height
	QPixmap p = quickviewer->renderPixmap();
	p.save( "test.png", "PNG" );
	// inspect that file and it contains garbage;
	// use p in the application and it shows up as garbage

You see, no moment when any deallocation occurs, as far as I can  
tell.  And yet, when I say "garbage" I mean streaks of random colors  
and little bits of other images in memory, indicating I'm accessing  
memory I shouldn't be accessing.  Thus, my confusion.

Anyone else run across this same Linux-specific problem?  Did I do  
something wrong?

Thanks!

Nathan




More information about the Qt-interest-old mailing list