剪切一个 QGLWidget?

发布于 2024-12-01 11:20:14 字数 128 浏览 2 评论 0原文

是否可以剪切QGLWidget?我的意思是我想剪切它,这样我就可以访问下面的图形用户界面。听起来很奇怪,但是将我的 QGLWidget 一分为二对我来说需要做很多工作。我希望你明白我的意思。

Is it possible to cut a QGLWidget? I mean I would like to cut it so i get access to the gui below. It sounds strange, but it would be a lot of work for me to divide my QGLWidget into two. I hope you understand what I mean.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

葬シ愛 2024-12-08 11:20:14

我不完全理解你所说的“剪切”和下面的 GUI 是什么意思。在正确使用布局机制的 Qt 中,小部件消耗其覆盖的区域,并且其下方没有小部件。

您想将多个视图渲染到单个 QGLWidget 中吗?通过正确使用glViewport + glScissor可以轻松实现这一点。


因评论而编辑

有两种窗口:

  • 顶级窗口(您可以在屏幕上自由移动的窗口)
  • 子窗口(顶级窗口中的小部件或窗格等子窗口)

子窗口再次出现两个特征:

  • 逻辑子窗口
  • 真正的子窗口

逻辑子窗口仅由其位置、维度和层组成,并由工具包管理。从操作系统的角度来看,只有一个顶层窗口。该工具包管理其内部状态,以在顶层窗口中给出独立同级窗口的印象。

真正的子窗口由操作系统/图形系统管理。这样的真实子窗口可以与它们的父窗口和同级窗口共享它们的图形上下文。然而,只有当创建 OpenGL 上下文的窗口具有自己的图形上下文时,OpenGL 才能正常工作。因此任何OpenGL子窗口都不可避免地会有它自己的图形上下文和图形系统窗口对象。大多数图形系统都不能正确支持将形状应用到子窗口(仅顶层窗口,这也与 OpenGL 冲突)。

因此,归根结底,尝试将 OpenGL 窗口“分层”在同级窗口之上几乎是不可能的,也不建议这样做。在某些情况下它可能会起作用,但大多数时候不会。

这是坏消息。

好消息是,你只是看错了方向。我特此将您的观点转向QGraphicsView。 QGraphicsView 支持 OpenGL 作为后端,您还可以编写自己的 OpenGL 渲染器代码在 QGraphicsView 中执行。但此外,QGraphicsView 也可以用于渲染小部件,也使用 OpenGL。因此,您所要做的就是将 OpenGL 渲染代码和小部件放入公共 QGraphicsView 场景中,然后就完成了。这是教程 http://www.crossplatform.ru/node/612 结果本教程的内容如下所示: 在此处输入图像描述

I don't fully understand what you mean by "cut" and GUI below. In Qt with layout mechanisms properly used a widget consumes the area it covers and there are no widgets beneath it.

Do you want to render multiple views into a single QGLWidget? This is easily achieved by proper use of glViewport + glScissor.


EDIT due to comment

There are two kinds of windows:

  • Top level (those you can freely move around on the screen)
  • Child windows (subwindows like widgets or panes in a top level window)

Child windows again come in two characteristics:

  • logical child
  • real child

A logical child window just consists of its position, dimension and layer and are managed by the toolkit. From the view of the operating system there's just one top level window. The toolkit is it that manages its internal state to give the impression of independent sibling windows in the toplevel window.

A real child window is manages by the operating/graphics system. Such real child windows may share their graphics context with their parent and sibling. However OpenGL only works well if the window into which a OpenGL context is created has its very own graphics context. Thus any OpenGL child window inevitably will have its very own graphics context and graphics system window object. Most graphics systems out there don't properly support applying shapes onto child windows (only toplevel windows, and then this also conflicts with OpenGL).

So this boils all down that it's virtually impossible, nor advisible to try to "layer" an OpenGL window on top of a sibling. It may work in some circumstances, but most of the time it won't.

That's the bad news.

The good news are, that you simply looked in a slightly wrong direction. I hereby direct your view towards QGraphicsView. QGraphicsView supports OpenGL as a backend, you can also write your own OpenGL renderer code to be executed within a QGraphicsView. But furthermore QGraphicsView can also be used for rendering widgets, also using OpenGL. So all you have to do is putting both your OpenGL rendering code and your widget into a common QGraphicsView scene and are done. And here is a tutorial http://www.crossplatform.ru/node/612 the result of the tutorial looks like this: enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文