QWebEngineView
渲染採用了OPENGL,但是實際使用有些用戶會遇見無法渲染出來控件的問題。
後來發現是他們的顯卡不大好,支持的OPENGL版本不夠。可以嘗試
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);
但是這個也不是純軟件的,當OPENGL版本小於2的時候還是渲染不出來。
QT的這個瀏覽器對老機器的支持感覺真心是不大好,所以面對大量用戶的軟件還是要慎用。
顯卡OpenGL版本查看測試工具GPU_Caps_Viewer
已經存到百度網盤,等需要了可以用來測試下
獲取OPENGL 版本的代碼
PIXELFORMATDESCRIPTOR pfd =
{
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, //Flags
PFD_TYPE_RGBA, //The kind of framebuffer. RGBA or palette.
32, //Colordepth of the framebuffer.
0, 0, 0, 0, 0, 0,
0,
0,
0,
0, 0, 0, 0,
24, //Number of bits for the depthbuffer
8, //Number of bits for the stencilbuffer
0, //Number of Aux buffers in the framebuffer.
PFD_MAIN_PLANE,
0,
0, 0, 0
};
HDC ourWindowHandleToDeviceContext = GetDC(NULL);
int letWindowsChooseThisPixelFormat;
letWindowsChooseThisPixelFormat = ChoosePixelFormat(ourWindowHandleToDeviceContext, &pfd);
SetPixelFormat(ourWindowHandleToDeviceContext, letWindowsChooseThisPixelFormat, &pfd);
HGLRC ourOpenGLRenderingContext = wglCreateContext(ourWindowHandleToDeviceContext);
wglMakeCurrent(ourWindowHandleToDeviceContext, ourOpenGLRenderingContext);
//const GLubyte * name = glGetString(GL_VENDOR);
//const GLubyte * OpenGLVersion = glGetString(GL_VERSION);
//****測試下opengl 功能*************//
const GLubyte * version = glGetString(GL_VERSION);
if (version != NULL)
{
int ver1, ver2, ver3;
int ret = sscanf((char*)version, "%d.%d.%d", &ver1, &ver2, &ver3);
if (ret <= 0 || ver1 < 3)//opengl 版本太低採用軟件渲染方式
{
QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);
}
}
wglDeleteContext(ourOpenGLRenderingContext);
ReleaseDC(NULL, ourWindowHandleToDeviceContext);
glGetString 在大部分機器上都執行正常,但是有一臺機器上獲取的是NULL,不知道什麼問題,難道是不支持OPENGL?