How does QGLWidget work in QT? - qt

Amazingly, i switched a QWidget to be a QGLWidget and now my QPainter::drawImage calls are 5x faster. I changed nothing else, except the widget type. How does that make QPainter calls perform better? I'm glad it works, but i just do not understand how. Any ideas?
Thanks.

The QGLWidget uses the OpenGL implementation you have available on your system, which may be hardware accelerated. It depends on your system. Qt widgets can be rendered using different QPaintEngine's.
You can even try to change the entire graphics system to use OpenGL by trying to run an application with the parameter -graphicssystem. This cannot be done currently in Qt for Linux Embedded. You can try the difference running the animatedtiles example for instance.
Note that this doesn't necessarily mean performance will be better than with the raster painter. It depends on the OpenGL implementation of the system, if it is only software, performance may be even worst.

It uses OpenGL for rendering its content.

If it's using OpenGL, it's probably also using hardware acceleration

Related

Implement with QML or C++?

I've just started learning Qt recently, finding QML quite interesting for implementing UI component. Before the project really kick off, I've got some questions:
For a fresh start project, should I just use QML? Does QML be designed for replacing QWidget?)
If I go with QML, is there anything else must be implemented with C++? Or better implemented with C++ for better performance? (I know some customized UI components can be integrated through plugin) What's the relationship between QML and C++ widget?
As for performance or rendering issue, does QML better than native C++ widget?
When you start a question with 'Should I use', it is quite a good hint that SO might not be the right place to ask it. Even more when there are only answers, which start with 'It depends on...'.
QML is not designed to replace QWidget. It is a different technique. Which one to use, depends on your requirements.
Whether or not you must implement additional stuff in C++ depends on your project. Some things are easier in C++, others in QML. And some stuff is not possible in QML at all.
There is no relationship between QML and C++ widgets.
And the performance of QML is in most cases more than sufficient. In almost every case QML is used to create user interfaces. I doubt that there are many cases where clicking a button or opening a dropbox folder is performance critical.
I had a chance to put this question to a few Qt experts at the World Summit today and the general take was that because QML component rendering can be done through hardware acceleration that it is preferred for apps requiring high performance graphics, eg automotive dashboards. OTOH widgets seem to be used for desktop applications. Another consideration is that while widgets can be styled using Qss (Qt's version of Css), QML components cannot.
In QML based applications computationally intensive functions are generally written in C++.
HTH,
Eric G

Embedding Qt GUI into existing OpenGL program

I'm currently trying to get Qt working with my existing program.
I'm using SFML for creating my OpenGL rendering context and creating the window. The things I tried out so far however always create a separate window by Qt instead of just rendering into the existing context.
Is there any way I can force Qt to render to an already existing OpenGL context?
I've not looked into the specifics, but this has been done for openage.
I think looking at the documentation for QQuickRenderControl might be a good place to start.
Qt wants full control over the windows and the event loop, so this will not work (unless you put a lot of effort into it). Your best bet is using a QGLWidget and emulate the event management of SFML with that, so that your application effectively runs on Qt. It is very well possible to render Qt widgets into a OpenGL window (Qt has a OpenGL widget backend) but this must be still managed by Qt itself.

Qt PowerVR driver mouse pointer unavailable

I am not trying to spam here just trying to be more specific about the issue of Qt mouse pointer not being available for PowerVR. So I hope someone will have a answer to my question.
Qt PowerVR driver needs to be compiled with QT_NO_QWS_CURSOR which stops usage of mouse but still leaves room for touch screens.
I just want to know why this is needed is it because of a hardware limitation or is it just a incomplete driver.
Thank you very much for assistanse well in advance.
I've never tried that driver, I just saw the code. I suppose that is only used for performance reasons. Placing a pointer requires Qt to do its own software compositing over hardware accelerated OpenGL graphics, reducing performance.
It is possible that simply omitting that definition your pointer appears, or anyway making it appear requires only to instantiate it. Consider anyway that if simple software cursor is used, it may not be good when placed over OpenGL surfaces. You might need an implementation using platform specific structures which you might have or might not. Sorry if I can't be of more help.

Qt+OpenGl+SimpleGl

I have enabled qt+OpenGl+SimpleGl on one of the ARM platform and was able to run opengl example programs.
I also has a qt+Webkit, which is working with a graphic plugin.
I wanted to use simpleGl context for every thing, instead of using the normal graphic screen. So, when I try to run Qt+Webkit with simpleGl, I just get a blank screen.
Does QT support this? If so how can we make it?
Yes, this is correct. OpenGL draws directly to the framebuffer. The simplegl driver doesn't handle what is drawn using the raster paint engine of the QWS, so you may see only black.
Using simplegl for "everything" means you want everything to be drawn using OpenGL in your EGL full-screen window? This is possible under some assumptions. You have to write all your applications to be rendered using the Qt OpenGL paint engine (using the opengl graphics system is not supported under Qt/E). This is possible also for QtWebKit, I'm doing it now. Note that this does not mean that everything is rendered using hardware acceleration. You'll have to write your applications "the right way" to get all actually hardware accelerated. Consider that you'll have to handle the mouse pointer some other way in this case.
The other way is to just modify the simplegl driver to allow for the use of Qt applications using the raster paint engine. This is possible as well with some limitations. Qt can use blit to place its own windows over OpenGL. Look for the framebuffer driver inside the Qt source tree to know how to do this. You can then have common Qt applications and OpenGL Qt applications some way. I'm doing this as well. Not everything can be done anyway.
EDIT: I'm sure you already did, but in case, give this http://doc.qt.io/qt-4.8/qt-embeddedlinux-opengl.html much attention.
Unfortunately I don't know anything about SimpleGL, but I do know that there is a way to render a standard Qt widget in a QGLWidget. Maybe have a look at this Qt Quarterly which I think is somewhat related to your question:
http://doc.qt.nokia.com/qq/qq26-openglcanvas.html

Rendering engine to load 3D model into Qt

I need an appropriate rendering engine to render a 3D model into Qt, and use Qt then as an event handler to this model. Thank you.
As for the rendering engine, you can go several directions, but I'll mention two. Qt comes with an OpenGL widget. You could make use of this by either:
writing your own rendering code to render your model using OpenGL
or
making use of a rendering engine/framework which has it's own Qt Widget (possibly derived from Qt's OpenGl widget). I know OpenSceneGraph has Qt integration available. And I seem to remember Ogre does as well. This just to mention two options. Just Google for Qt and your favorite engine and you'll most likely find something suitable. And if not, it is usually not that difficult to write your own integration if you feel like it.
Whichever option is more suitable for you depends on the exact specification of what you're trying to achieve. You probably know that better than we do.
As for the event handling, you might want to be a bit more specific as to what you mean.

Resources