Using Qt widgets in OpenGL application

  • Is there a way to use QTextEdit, QPushButton and other widgets and layouts in OpenGL application? For example, if I want styled text field with editable text, selection, copy&paste and a button to process this text in my game. Or should I use low-level features? If so, then from which features should I start? I can render text using QOpenGLTexture, QFontMetrics and QPainter, but instead I'd like to use QLabel.

  • Hi! If all you need is an overlay with controls over the scene, then you can simply place widgets on top of a QOpenGLWidget. If you somehow want to embed widgets in a 3D scene: no, that's not supported. In this case better use a game engine.

  • @Wieland My hobby for this month is own game engine :) And I think I've found a solution: rich text related classes QTextDocument, QTextLayout, QTextCursor etc. Rich text can be edited programmatically and rendered into texture using QPainter. I can create own text widgets.

  • There are also libraries that you can use in your OpenGL side to implement various UI features,

    CeGUI comes to my mind, but there are others.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.