gpt4 book ai didi

c++ - QOpenGLWidget 粉碎显示

转载 作者:行者123 更新时间:2023-11-30 02:14:32 26 4
gpt4 key购买 nike

我在 QMainWindow 实例 w 中嵌入了一个 QOpenGLWidget。编译正常。但是在调试时,程序在 w.show() 处崩溃。

错误对话框显示:

Exception thrown at 0x000007FEE5AF4469 (d3d11sdklayers.dll) in TestQtOpenGL.exe: 0xC0000005: Access violation reading location 0x00000806E5B03A98.

调用堆栈是:

d3d11sdklayers.dll!000007fee5af4469()   Unknown
d3d11sdklayers.dll!000007fee5ad2971() Unknown
libGLESv2d.dll!000007fed7d58a8d() Unknown
libGLESv2d.dll!000007fed7d56313() Unknown
libGLESv2d.dll!000007fed7d55521() Unknown
libGLESv2d.dll!000007fed7b2308a() Unknown
libGLESv2d.dll!000007fed7b24f1b() Unknown
libGLESv2d.dll!000007fed79dbba8() Unknown
libGLESv2d.dll!000007fed7bf2678() Unknown
libEGLd.dll!000007feecd1209d() Unknown
qwindowsd.dll!000007fed86752ac() Unknown
qwindowsd.dll!000007fed8674906() Unknown
qwindowsd.dll!000007fed8602d55() Unknown
qwindowsd.dll!000007fed8602999() Unknown
qwindowsd.dll!000007fed860223b() Unknown
qwindowsd.dll!000007fed86020fe() Unknown
Qt5Guid.dll!000007fed93a18a0() Unknown
Qt5Widgetsd.dll!0000000057d55dc2() Unknown
Qt5Widgetsd.dll!0000000057d97037() Unknown
Qt5Widgetsd.dll!0000000057d95d45() Unknown
Qt5Widgetsd.dll!0000000057d439f6() Unknown
Qt5Widgetsd.dll!0000000057d95fa9() Unknown
Qt5Widgetsd.dll!0000000057ce700e() Unknown
Qt5Widgetsd.dll!0000000057ce46c6() Unknown
Qt5Cored.dll!0000000058c15af6() Unknown
Qt5Cored.dll!0000000058c20c32() Unknown
Qt5Widgetsd.dll!0000000057d520b0() Unknown
Qt5Widgetsd.dll!0000000057d523f0() Unknown
Qt5Widgetsd.dll!0000000057d3dd71() Unknown
Qt5Widgetsd.dll!0000000057d3e0c9() Unknown
Qt5Widgetsd.dll!0000000057d50b12() Unknown
Qt5Widgetsd.dll!0000000057d52411() Unknown
Qt5Widgetsd.dll!0000000057d3dd71() Unknown
Qt5Widgetsd.dll!0000000057d3e0c9() Unknown
> TestQtOpenGL.exe!main(int argc, char * * argv) Line 9 C++ TestQtOpenGL.exe!WinMain(HINSTANCE__ * __formal, HINSTANCE__ * __formal, char * __formal, int __formal) Line 104 C++
[External Code]

演示:

// main.cpp

#include "TestQtOpenGL.h"
#include <QtWidgets/QApplication>

int main(int argc, char *argv[])
{

/*
* According to some solutions, I have tried the following
* codes, but no use.
*/
// QSurfaceFormat format; format.setDepthBufferSize(24);
// format.setStencilBufferSize(8);
// format.setVersion(4, 3);
// format.setProfile(QSurfaceFormat::CoreProfile);
// QSurfaceFormat::setDefaultFormat(format);

QApplication a(argc, argv);
TestQtOpenGL w;
w.show();
return a.exec();
}

// TestQtOpenGL.h
#pragma once
#include <QtWidgets/QMainWindow>
#include <qopenglwidget.h>

class TestQtOpenGL : public QMainWindow
{
Q_OBJECT
public:
TestQtOpenGL(QWidget *parent = Q_NULLPTR);
private:
QOpenGLWidget *glwidget;
};
// TestQtOpenGL.cpp
#include "TestQtOpenGL.h"

TestQtOpenGL::TestQtOpenGL(QWidget *parent)
: QMainWindow(parent)
{
setFixedSize(800, 600);
glwidget = new QOpenGLWidget(this);
setCentralWidget(glwidget);
}

环境:

  • Qt 5.9.4 msvc2015 64 位
  • Visual Studio 2015
  • Windows 7

根据@Aleph0 的建议,我使用 [Visual Studio]->[Debug]->[Windows]->[Modules] 调查了加载的模块。但是我没有发现任何可疑的 DLL。模块列表已上传here .

最佳答案

受到@RoQuOTriX 的启发,我以一种非常简单的方式解决了这个问题:

在 Windows 设备管理器中更新图形驱动程序。然后重启。重新编译,问题消失。

请注意,我的显卡是 Intel HD Graphics。如果您使用的是独立显卡,则可能需要从设备提供商处获取显卡驱动程序更新。

关于c++ - QOpenGLWidget 粉碎显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57671697/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com