首页| 论坛| 消息

回复: 求助:打包以后,有的时候弹出缺少opengl,有的时候正常
#6 回 fsu0413 的帖子 [wangjianxyz 08-20 14:28]
fsu0413:UI只能在主线程用 (2021-07-24 08:32) 
现在情况又有变化了。我在qtcreator里面,启动程序,有时也会启动失败。再来一次又好了。
我的Qt是5.9.7
qt creator打印如下:
createContext: wglCreateContextAttribsARB() failed (GL error code: 0x0) for format: QSurfaceFormat(version 2.0, options QFlags(), depthBufferSize 24, redBufferSize -1, greenBufferSize -1, blueBufferSize -1, alphaBufferSize -1, stencilBufferSize 8, samples -1, swapBehavior QSurfaceFormat::SwapBehavior(DoubleBuffer), swapInterval 1, profileQSurfaceFormat::OpenGLContextProfile(NoProfile)), shared context: 0x0 (操作成功完成。)
createContext: wglCreateContext failed. (操作成功完成。)
Unable to create a GL Context.
Failed to create OpenGL context for format QSurfaceFormat(version 2.0, options QFlags(), depthBufferSize 24, redBufferSize -1, greenBufferSize -1, blueBufferSize -1, alphaBufferSize -1, stencilBufferSize 8, samples -1, swapBehavior QSurfaceFormat::SwapBehavior(DoubleBuffer), swapInterval 1, profileQSurfaceFormat::OpenGLContextProfile(NoProfile)) .
This is most likely caused by not having the necessary graphics drivers installed.
Install a driver providing OpenGL 2.0 or higher, or, if this is not possible, make sure the ANGLE Open GL ES 2.0 emulation libraries (libEGL.dll, libGLESv2.dll and d3dcompiler_*.dll) are available in the application executable's directory or in a location listed in PATH.
14:25:46: D:/share/htinventgit/output_exe/MonitorAgv-exe/MonitorAgvVer3 exited with code 3
#7 [lixinwei 08-20 18:52]
有没有可能是Qt 5.9的bug?换成Qt 5.12和5.15会不会发生类似现象?
有没有可能是电脑的问题?换其他电脑是否会有类似现象?
#8 [wangjianxyz 08-26 15:00]
我是发帖人,我总结一下。
最开始的时候,我的Qt程序打包给别人以后,偶尔会出现opengl的提示;
我根据网上的提示,在代码里,加上了“qputenv("QT_OPENGL", "software");”
加上以后,我自己这边其实没感觉到变化的;

就在几天前,我换了新电脑,然后,问题突然变的严重了。
我用qt creator编译运行程序,都会出现opengl的提示,非常影响编译效率;
几乎是运行3次就得有一次运行失败,出现opengl的提示;
#9 [wangjianxyz 08-26 15:01]
我试着新建了一个工程, 连续运行10次,都是正常的,没有报opengl的提示。
然后我又去折腾代码。最终发现,把“qputenv("QT_OPENGL", "software");” 去掉就可以了。
去掉以后,我这边用qt creator编译运行是没问题的。至于,以后打包会不会再出问题,还需要观察。
#10 [liudianwu 08-26 17:59]
qputenv("QT_OPENGL", "software")应该是相当于QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);

<< 1 2 >> (2/2)

回复 发表
主题 版块