[Qt-interest] custom widgets and OpenGL

Tyler Daniel tyler at rosette-research.com
Fri Nov 12 11:35:53 CET 2010


Wow!  Thanks for the very detailed response!

>> 2) anyone know of any reasons to not use a QGLWIdget (subclass) as a window?
> 
> Uhm... you HAVE to subclass QGLWidget, in order to re-implement the initializeGL(), updateGL() and resizeGL() methods, to actually get some meaningful rendering done ;)

I mean that the two options are 1) use a subclass of QGLWidget as my top-level == window widget, or 2) use a QGraphicsView as my top-level widget.  I read a thread somewhere that said there were problems with 1) when the window was both full-screen and unfocused.

So maybe my question should have been:  is anyone using a QGLWidget subclass as a top-level widget/window in full-screen mode with no problems?

>> 3) if I go the QGLWidget subclass route, would it be easy to add in Qt widgets /
>> text rendering later by creating a QPainter, or something like that?
> 
> There is an example which shows you how to mix QPainter with GL calls:
> 
>  http://doc.qt.nokia.com/4.7/opengl-overpainting.html

Thanks for the link, I'll check this one out.  Also the Qt Labs link.

> Uhm... and just now I found this article which pretty much shows what you want, I guess. Apparently you CAN use "raw OpenGL commands" inside a QGraphicsView! Here is how:
> 
>  http://doc.trolltech.com/qq/qq26-openglcanvas.html

Yep.  This is what I'm doing now as a test.  It works, but it feels a little too complex.  I don't have a lot of items that I want Qt to manage for me.  Also it feels a little strange to be doing the rendering in the scene and not the view, but that's a different discussion.

Thanks again for the feedback!

Does anyone else have any good ideas on how best to build a custom widget rendered in OpenGL?

Tyler



More information about the Qt-interest-old mailing list