Can QWidgets be added to QWindow?

时光总嘲笑我的痴心妄想 提交于 2019-12-11 00:03:08

问题


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?


回答1:


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.

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

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



来源:https://stackoverflow.com/questions/23929017/can-qwidgets-be-added-to-qwindow

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!