简体   繁体   English

切掉QGLWidget?

[英]Cut QGLWidget?

Is it possible to cut a QGLWidget? 是否可以切割QGLWidget? I mean I would like to cut it so i get access to the gui below. 我的意思是我想削减它,以便我可以访问下面的gui。 It sounds strange, but it would be a lot of work for me to divide my QGLWidget into two. 听起来很奇怪,但是将我的QGLWidget分成两部分对我来说是很多工作。 I hope you understand what i mean. 我希望你明白我的意思。 Thank you 谢谢

I don't fully understand what you mean by "cut" and GUI below. 我不完全理解您所说的以下“剪切”和GUI的含义。 In Qt with layout mechanisms properly used a widget consumes the area it covers and there are no widgets beneath it. 在具有正确使用的布局机制的Qt中,小部件会占用其覆盖的区域,并且其下方没有小部件。

Do you want to render multiple views into a single QGLWidget? 是否要将多个视图呈现到单个QGLWidget中? This is easily achieved by proper use of glViewport + glScissor . 正确使用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. 但是,只有在创建OpenGL上下文的窗口具有其自己的图形上下文的情况下,OpenGL才能很好地工作。 Thus any OpenGL child window inevitably will have its very own graphics context and graphics system window object. 因此,任何OpenGL子窗口都将不可避免地具有其自己的图形上下文和图形系统窗口对象。 Most graphics systems out there don't properly support applying shapes onto child windows (only toplevel windows, and then this also conflicts with OpenGL). 那里的大多数图形系统不正确地支持在子窗口(仅顶层窗口,然后与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. 因此,这归结为几乎不可能,也不是试图将“ OpenGL”窗口“叠加”在同级之上的可见性。 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 QGraphicsView supports OpenGL as a backend, you can also write your own OpenGL renderer code to be executed within a QGraphicsView. QGraphicsView支持OpenGL作为后端,您也可以编写自己的OpenGL渲染器代码以在QGraphicsView中执行。 But furthermore QGraphicsView can also be used for rendering widgets, also using OpenGL. 但是此外,QGraphicsView也可以用于渲染小部件,也可以使用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. 因此,您要做的就是将OpenGL渲染代码和小部件都放入一个常见的QGraphicsView场景中并完成。 And here is a tutorial http://www.crossplatform.ru/node/612 the result of the tutorial looks like this: 这是一个教程http://www.crossplatform.ru/node/612 ,该教程的结果如下所示: 在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM