I'm trying to create a OpenGL
widget using Qt 6.4
and VStudio 2022
, i have enable the Qt OpenGL
widget under the modules, but i still getting a lot of compile errors:
LNK2019 unresolved external symbol "__declspec(dllimport) public: __cdecl QOpenGLWidget::QOpenGLWidget(class QWidget *,class QFlags<enum Qt::WindowType>)" (__imp_??0QOpenGLWidget@@QEAA@PEAVQWidget@@V?$QFlags@W4WindowType@Qt@@@@@Z) referenced in function "public: void __cdecl Ui_MainWindowClass::setupUi(class QMainWindow *)" (?setupUi@Ui_MainWindowClass@@QEAAXPEAVQMainWindow@@@Z)
I'm testing in a 'clean' project containing nothing more than a OpenGlWidget
added trough QT Designer.
The includes i have added:
#include <QtWidgets>
#include <QtOpenGL>
My project configuration:
I have also tried adding, into Linker -> General -> Additional Library directories
:
D:\Qt\6.4.0\msvc2019_64\lib;
And at Linker -> Input -> Additional Dependencies
:
Qt6OpenGL.lib
But i continue getting the same errors.
I have installed everything in the Qt Maintenance tool
, what i'm missing?
CodePudding user response:
QOpenGLWidget
has been moved to Qt OpenGL Widgets module.
You must to link against both Qt6OpenGL.lib
and Qt6OpenGLWidget.lib
.
https://doc.qt.io/qt-6/opengl-changes-qt6.html#the-qopenglwidgets-class
CodePudding user response:
Which help from Qt Forum, I found that these errors were being caused because I was missing adding the openglwidgets
module into the project.
After setting Qt Modules
to core;gui;widgets;opengl;openglwidgets
it compiled successfully.
It strange that the module openglwidgets
is missing in the plugin window of Qt Modules
, should be reported as a bug/missing?