Qt6, qmake: Does 'QT += openglwidgets' imply 'QT += opengl'?
-
In the pro file for a Qt6 project which uses the QOpenGLWidget class, it is necessary to add
openglwidgets
toQT
(source). In practice, the project will now compile without explicitly addingopengl
toQT
. Does the former addition make the latter redundant, or is this not behavior that can be relied upon?In other words, which is the correct configuration? This:
QT += openglwidgets
or this:
QT += opengl openglwidgets
?The Qt6/OpenGL examples use
QT += widgets opengl openglwidgets
(source), but I cannot rule out that this for backwards compatibility with Qt5 (or earlier). -
If the first works why don't you simply use it. I would guess qopenglwidget.prf fetches qopengl.prf - you can take a look into them by your own.
-
@Christian-Ehrlicher said in Qt6, qmake: Does 'QT += openglwidgets' imply 'QT += opengl'?:
If the first works why don't you simply use it. I would guess qopenglwidget.prf fetches qopengl.prf - you can take a look into them by your own.
If it works and it's unspecified behavior, then it may not work on other machines or for future Qt versions.
Excuse my ignorance, but how can I find those files? I can find 'opengl.prf' (without the 'q'), but not 'qopenglwidget.prf' (with or without the 'q'). I've tried clicking on it in Qt Creator and searching the Qt install folders.
-
@Yuni said in Qt6, qmake: Does 'QT += openglwidgets' imply 'QT += opengl'?:
If it works and it's unspecified behavior, then it may not work on other machines or for future Qt versions.
Build and module dependencies usually don't change in a minor Qt version. For major Qt versions, things might get rearranged ... but then again there's no SC guarantee there in the first place :)
I think it's good practice to explicitly declare all the dependencies that you explicitly rely upon though. But this is arguably a matter of taste.
I would guess qopenglwidget.prf fetches qopengl.prf - you can take a look into them by your own.
For
QT
variable, it's actually.pri
files:mkspecs/modules/qt_lib_qopenglwidgets.pri
,mkspecs/modules/qt_lib_qopengl.pri
... -
@kkoehne said in Qt6, qmake: Does 'QT += openglwidgets' imply 'QT += opengl'?:
@Yuni said in Qt6, qmake: Does 'QT += openglwidgets' imply 'QT += opengl'?:
If it works and it's unspecified behavior, then it may not work on other machines or for future Qt versions.
Build and module dependencies usually don't change in a minor Qt version. For major Qt versions, things might get rearranged ... but then again there's no SC guarantee there in the first place :)
I think it's good practice to explicitly declare all the dependencies that you explicitly rely upon though. But this is arguably a matter of taste.
I would guess qopenglwidget.prf fetches qopengl.prf - you can take a look into them by your own.
For
QT
variable, it's actually.pri
files:mkspecs/modules/qt_lib_qopenglwidgets.pri
,mkspecs/modules/qt_lib_qopengl.pri
...I see, thank you so much! I'll declare them explicitly then.
I've found the
.pri
files (without the leading 'q', that is, so e.g.qt_lib_opengl.pri
) and openglwidgets indeed has a dependency on opengl, explaining why the project compiles without the explicit declaration.