Planned maintenance: From Sunday 8th December 10:00 CET there will be changes to try and solve the caching issues that have been experienced. If anyone has a problem connecting after this period then please PM @AndyS or any of the moderators.
Widgets in OpenGL.
While browsing in Qt sources, i noticed that all painting in widgets is done via QPainter. Qt has QPainter implementation even for OpenGL, so it should be possible to use widgets in OpenGL only by switching the QPainter implementation?
That's not really how this works. Qpainter paints on QpaintDevice implementation. QWidget is one of such implementations, using raster operations, QOpenGLPaintDevice is another, using OpenGL.
So if you wanted to draw widgets using OpenGL you would essentially have to rewrite QWidget. The other option is to render them to an image using existing raster engine and use that as a texture in OpenGL.
There was an experimental OpenGL backend for widgets back in Qt 4.8, but it was dropped in Qt5 (if I remember correctly it presented various performance and architectural difficulties).
@Chris-Kawa Please do you know what performance issues it had?
It was a long time ago but you can dig through mailing list archives to hunt for details. A place to start as good as any is here. All in all it was dropped in favor of QML and specialized widgets and windows for OpenGL rendering (QGLWidget, QOpenGLWidget and QWindow with OpenGL surface).
@Chris-Kawa But if i need application like game-engine where i want good viewport (that "widget" where you manipulate with models etc.) performance, i don't wanna that way QOpenGLWidget does, because i think it renders OpenGL to some buffer on GPU and than move that buffer to RAM to show it as software rendered picture (so again move to GPU ? :D). But i still need all these buttons, layout classes etc. that Qt has for good GUI. It would be amazing to have QWidgets on OpenGL.
i think it renders OpenGL to some buffer on GPU and than move that buffer to RAM to show it as software rendered picture
Someone might correct me on that but I think it's the other way around. The OpenGL stuff is rendered to an FBO, the ui is rendered to an image used as a texture and then the final composition happens on the GPU.
As for the widgets - there's no (easy?) way to draw them using OpenGL and keep the native look. I don't know of any OS api that would let you render native controls to an OpenGL buffer, so you would pay the price anyway. Also Qt often uses native methods (e.g. for dialogs) and there would be no way to render these this way.
For list of possible ways to mix widgets with OpenGL check these blog entries: link, link.
If you want to use widgets inside a 3D scene in OpenGL accelerated window then it's another story. I think there were demos using OpenGL accelerated QGraphicsView but I'm fuzzy on details now.
KrabQT last edited by KrabQT
I don't know, there are too many options.
I will definitely need relative complex GUI (similiar to IDE) and i want my custom look (app should look same on all platforms).
I would do it even in Qt Quick 2 and QML, but i can't find any complex app made in it to see how it is responsive, if the UI is without delays.
Somewhere in that mailing list i found one time that the QML is good for small embedded applications, but not play very well on big complex apps on desktop.
I will probably go with Qt Widgets and use that QWidget::createWindowContainer, because i can say that if there will be some GL content in my app, it will be the "center widget" in my app. Hope there will be not much flickering when resize/show/hide that native widget.