本文介绍了可以将QWidgets添加到QWindow吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

现在建议使用QWindow进行OpenGL绘制.是否可以在此窗口中添加小部件?如果是这样,怎么办?如果没有,我应该如何使用Qt5将小部件添加到OpenGL程序中?

It's now recommended to use QWindow for OpenGL drawing. Is it possible to add a widget to this window? If so, how? If not, how should I go about adding widgets to an OpenGL program using Qt5?

推荐答案

应用程序通常将QWidgetQQuickView用于其UI,而不直接使用QWindow. QWindowQWidget更低电平.如果要直接使用QWindow,则需要完成更多工作.您应该手动完成所有与绘图相关的操作,这并不容易.

An application will typically use QWidget or QQuickView for its UI, and not QWindow directly. QWindow is more low level than QWidget. If you want to use QWindow directly, more work is needed to accomplish the job. You should manually do all drawing related things which is not easy.

但是,如果您确实希望使用QWindow/QGuiApplication而不是QWidget/QApplication,则可以使用 QBackingStore QWidget使用,或SceneGraphSceneGraphQWindow::exposeEvent()中使用.

However, if you really want a QWindow/QGuiApplication instead of QWidget/QApplication, you can use QBackingStore which is used by QWidget, or SceneGraph which is used by QQuick in QWindow::exposeEvent().

您可以使用QPainter QWindow的应用程序的示例="nofollow">此处.

You can see an example of a minimal QWindow based application using QPainter here.

这篇关于可以将QWidgets添加到QWindow吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 05:04