切掉QGLWidget? [英] Cut QGLWidget?

查看:137
本文介绍了切掉QGLWidget?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以切割QGLWidget?我的意思是我想削减它,以便我可以访问下面的gui.听起来很奇怪,但是将我的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. Thank you

推荐答案

我不完全理解您在下面的剪切"和GUI的意思.在使用适当布局机制的Qt中,小部件会占用其覆盖的区域,并且其下方没有小部件.

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.

是否要将多个视图呈现到单个QGLWidget中?正确使用 glViewport + glScissor 即可轻松实现.

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

由于评论需要编辑

有两种窗口:

  • 最高级别(您可以在屏幕上自由移动的那些)
  • 子窗口(子窗口,如顶层窗口中的小部件或窗格)

子窗口再次具有两个特征:

Child windows again come in two characteristics:

  • 逻辑孩子
  • 真正的孩子

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

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.

真正的子窗口由操作系统/图形系统管理.这样的真实子窗口可以与其父级和同级共享它们的图形上下文.但是,只有在创建OpenGL上下文的窗口具有其自己的图形上下文的情况下,OpenGL才能很好地工作.因此,任何OpenGL子窗口都将不可避免地具有其自己的图形上下文和图形系统窗口对象.那里的大多数图形系统不正确地支持在子窗口(仅顶层窗口,然后与OpenGL冲突)上应用形状.

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).

因此,这归结为几乎不可能,也没有试图将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.

那是个坏消息.

好消息是,您只是看了一个稍微错误的方向.在此,我将您的观点引向 QGraphicsView . QGraphicsView支持OpenGL作为后端,您也可以编写自己的OpenGL渲染器代码以在QGraphicsView中执行.但是此外,QGraphicsView也可以用于渲染小部件,也可以使用OpenGL.因此,您要做的就是将OpenGL渲染代码和小部件都放入一个通用的QGraphicsView场景中并完成.这是一个教程 http://www.crossplatform.ru/node/612 结果该教程的内容如下所示:

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:

这篇关于切掉QGLWidget?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆