Qt widgets mixed with QML on top
I would like to use two widgets (one at a time) as the base / background of my application, with a QML UI on top of it and a borderless window. It should look like this:
- OpenGL Scanning Component
- A 3D rendering component that works through a window handle
- Multiple QML UI components as overlays (possibly draggable)
- QML sidebar component
I have successfully achieved including component 1 in the QGLWidget and displaying the QML components on top of it. Worked without problems.
However, I am having trouble getting component 2 to work. I can do this easily if I include it in a top level QWidget and use it winId
to access the handle. Unfortunately, I cannot base myself on this. I've looked at several options, but none of them fit:
- If I go along the QWidget path, the component is on top and the QML components cannot overlap.
- I tried to get it to work with QGraphicsProxyWidget, but it just displays an empty gray widget.
- I read that the new (er) way is to use a QWidget based app and use QtQuick2 for overlays. But then again, it seems that this only works for OpenGL based components.
- It might also be possible to use QQuickWidget and QOpenGLWidget available in Qt 5.3 and 5.4, but I have no idea how or how this works as I have not seen examples that fit my purpose.
- There might also be an option
QWidget::createWindowContainer
, but it does not allow (transparent) overlays.
My problem is that I don't know how to overlay a non-GL widget with QML and then how to include everything in one application (possible parental problems setViewport
when switching between two widgets). Has anyone ever done this or can point out a direction that might show results?
I am using Qt 5.2.1, VS2012 and x64 assembly (requirement), targeting Windows desktop.
Of course, it would be nice to have an efficient solution, perhaps based on QtQuick2, but I am so confused that I would accept anything that would at least make it work for the moment.
source to share