1

I am new to C++, OpenGL, and QT. In fact, I’ve never even touched QT. The reason for this is the following; I’ve made games in a few other languages in the past (mostly C# with Unity). Now I want to get into games with c++. However, I want to use pure C++, not even Unreal (maybe one day ), for games. To do this I know that for graphics I should almost definitely be using OpenGL (which I’m currently learning). I also am going to need to make GUIs. When I looked up what to use, it looked like the best option would probably be QT. This means I need QT to work with OpenGL. So again I looked it up. I found QT OpenGL on this post: How to work with OpenGL and QT?. When I looked up Qt OpenGL (https://doc.qt.io/qt-5/qtopengl-index.html) it said:

Warning: This module should not be used anymore for new code. Please use the corresponding OpenGL classes in Qt GUI.

So what is QT GUI? And, how easy it to use QT with OpenGL?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
BeastCoder
  • 2,391
  • 3
  • 15
  • 26
  • 1
    Of course you can use Qt for OpenGL drawing [docs](https://doc.qt.io/qt-5/qtgui-index.html). It's just Qt had some classes that now are deprecated. Perhaps a more "pure" approach of using OpenGL stuff is using `glfw` or `sfml` or `wxWidgets` instead of Qt. – Ripi2 Oct 16 '19 at 19:35
  • In SO you just have to have only one question per post, if not, your question would be too broad by asking it off-topic for SO. – eyllanesc Oct 16 '19 at 19:44
  • @Ripi2 I am using GLFW. Does that handle GUIs? – BeastCoder Oct 16 '19 at 23:35
  • 2
    @BeastCoder: GLFW does handle windows, input events, and other things, that Qt does as well. In general you can not mix GLFW with Qt. – datenwolf Oct 17 '19 at 13:45
  • I still remember Qt being way ahead of anything else in the late 90s. When you use Qt now, your design decisions and application deployment are effectively dominated by Qt. You don't simple *use* the Qt libraries - you are very much developing a Qt application. That's not a bad thing in UI driven apps - but if you're creating games, I suggest GLFW, which allows for direct control of the event loop. – Brett Hale Oct 17 '19 at 15:23

2 Answers2

6

As the new features of Qt 5.4 point out, the Qt Opengl module has been declared deprecated.

Deprecated features

  • Qt OpenGL:

    • The Qt OpenGL module (which contain classes that start with "QGL") is now deprecated in favor of the Qt GUI module (which contain classes that start with "QOpenGL"). QGLWidget can now be replaced by QOpenGLWidget.

That does not imply that:

  • the module has been removed but at any time Qt could remove it without notice.

  • You cannot use opengl in Qt, only you should not use the QGLX classes that belong to the Qt OpenGL package but you must use the QOpenGLX classes of the Qt Gui module, for example replace QGLWidget with QOpenGLWidget.

You can also find several examples here.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
  • Thanks so much! I just had one question. You said I cannot use OpenGL in QT, then said I “should not use the QGLX classes that belong to the QOpenGLX package but must use the QOpenGLX classes of Qt Gui module” so I can or cannot use OpenGL? Could you please clarify? Thanks for the great answer! – BeastCoder Oct 16 '19 at 23:31
  • @BeastCoder In simple: Qt moved the classes from Qt OpenGL to Qt Gui and renamed them, in doing so it is unnecessary to keep Qt OpenGL so that Qt deleted them. So you can use opengl in Qt as shown in the examples provided in the link. – eyllanesc Oct 16 '19 at 23:41
  • Thanks so much! I’ll have to learn how this all differs from GLFW. Is it a big change or more of an easy transition? – BeastCoder Oct 17 '19 at 00:46
1

Qt is probably not the right tool for you. For one you want to use GLFW, which would cross into the turf of Qt and vice versa. A much better choice for game UI stuff is Dear ImGUI which is far better suited for the needs of game development.

datenwolf
  • 159,371
  • 13
  • 185
  • 298