QWebEngineView控件由于使用了opengl,在某些电脑上可能由于opengl的驱动过低会导致花屏
或者各种奇奇怪怪的问题,比如showfullscreen的情况下鼠标右键失效,需要在main函数启用软
件opengl渲染。
#if (QT_VERSION > QT_VERSION_CHECK(5,4,0))
//下面两种方法都可以,Qt默认采用的是AA_UseDesktopOpenGL
QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
//QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);
#endif
QApplication a(argc, argv);
另外一个方法解决 全屏+QWebEngineView控件一起会产生右键菜单无法弹出的bug,需要上移一个像素
QRect rect = qApp->desktop()->geometry();
rect.setY(-1);
rect.setHeight(rect.height());
this->setGeometry(rect);
QWebEngineView控件使用异常问题(10)
最新推荐文章于 2025-03-25 18:14:20 发布