[英]Qt widgets mixed with QML on top
I would like to use two widgets (one at a time) as the basis/background of my application, with a QML UI on top of it and a borderless window. 我想使用两个小部件(一次一个)作为我的应用程序的基础/背景,在它上面有一个QML UI和一个无边框窗口。 It should look like this:
它应该如下所示:
layout http://fs1.directupload.net/images/141211/cruvrltu.png 布局http://fs1.directupload.net/images/141211/cruvrltu.png
I have successfully achieved to include component 1 into a QGLWidget and have the QML components displayed on top of it. 我已经成功地将组件1包含到QGLWidget中,并在其上显示QML组件。 Worked without a problem.
工作没有问题。
However, I fail to make component 2 work. 但是,我无法使组件2工作。 I can do it easily if I include it into a top-level QWidget and use its
winId
to access the handle. 如果我将它包含在顶级QWidget中并使用其
winId
来访问句柄,我可以轻松完成。 Unfortunately, I cannot build on top of that. 不幸的是,我无法在此基础上进行构建。 I went through several options, but none of them seems to suffice:
我经历了几个选项,但它们似乎都不够:
QWidget::createWindowContainer
, but it does not allow (transparent) overlays. QWidget::createWindowContainer
的选项,但它不允许(透明)叠加。 My problem is that I don't know how to overlay a non-GL widget with QML and then later how to include everything into one application (possible parent problems with setViewport
when switching between the two widgets). 我的问题是我不知道如何用QML覆盖非GL小部件,然后如何将所有内容都包含在一个应用程序中(当在两个小部件之间切换时,
setViewport
可能存在父问题)。 Has anyone ever done this or can point in a direction which might show results? 有没有人做过这个或者可以指出可能显示结果的方向?
I am using Qt 5.2.1, VS2012 and build for x64 (requirement), targeting Windows desktop. 我正在使用Qt 5.2.1,VS2012和针对x64(需求)构建,针对Windows桌面。
It would of course be good to have a performant solution, maybe based on QtQuick2, but I am at such a loss that I would accept anything that at least would make it work for the moment. 拥有一个高性能的解决方案当然是好的,可能基于QtQuick2,但是我很遗憾,我会接受任何至少会让它暂时工作的东西。
In the end, I went with using a QWindow, take its window handle for integrating the 3D visualization and then overlaying it with QQuickView components (with the QWindow as parent). 最后,我使用QWindow,使用其窗口句柄来集成3D可视化,然后将其与QQuickView组件(QWindow作为父组件)重叠。 The only drawback of that solution is that it does not allow for transparency.
该解决方案的唯一缺点是它不允许透明。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.