简体   繁体   中英

Can QWidgets be added to QWindow?

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?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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