[英]How to create a OpenGL widget in Qt and VIsual Studio?
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:我正在尝试使用
Qt 6.4
和VStudio 2022
创建一个OpenGL
小部件,我在模块下启用了Qt OpenGL
小部件,但我仍然遇到很多编译错误:
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.我正在一个“干净”的项目中进行测试,其中仅包含一个
OpenGlWidget
Designer 添加的 OpenGlWidget。
The includes i have added:我添加的包括:
#include <QtWidgets>
#include <QtOpenGL>
My project configuration:我的项目配置:
I have also tried adding, into Linker -> General -> Additional Library directories
:我也尝试将其添加到
Linker -> General -> Additional Library directories
:
D:\Qt\6.4.0\msvc2019_64\lib;
And at Linker -> Input -> Additional Dependencies
:在
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?我已经安装了
Qt Maintenance tool
中的所有内容,我缺少什么?
QOpenGLWidget
has been moved to Qt OpenGL Widgets module. QOpenGLWidget
已移至 Qt OpenGL Widgets 模块。 You must to link against both Qt6OpenGL.lib
and Qt6OpenGLWidget.lib
.您必须同时链接
Qt6OpenGL.lib
和Qt6OpenGLWidget.lib
。
https://doc.qt.io/qt-6/opengl-changes-qt6.html#the-qopenglwidgets-class https://doc.qt.io/qt-6/opengl-changes-qt6.html#the-qopenglwidgets-class
Which help from Qt Forum, I found that these errors were being caused because I was missing adding the openglwidgets
module into the project.求助Qt论坛,我发现这些错误是因为我没有在项目中添加
openglwidgets
模块。
After setting Qt Modules
to core;gui;widgets;opengl;openglwidgets
it compiled successfully.将
Qt Modules
设置为core;gui;widgets;opengl;openglwidgets
后编译成功。
It strange that the module openglwidgets
is missing in the plugin window of Qt Modules
, should be reported as a bug/missing?奇怪的是,
Qt Modules
openglwidgets
应该报告为错误/缺失吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.