问题描述
我正在尝试让QtWebEngine在VM上运行,并且遇到了困难.根据这个问题的答案:
I'm trying to get QtWebEngine running on a VM and am having difficulties. According to the answer to this question:
有没有一种方法可以使QtWebEngine在不使用OpenGL的情况下工作?我没有直接使用任何OpenGL调用,也不需要任何3d功能.我只想嵌入QWebEngineView
来显示动态HTML页面.我猜测这应该可行,因为Chrome可以在同一个VM上正常工作.
Is there a way to get QtWebEngine to work without OpenGL? I'm not directly using any OpenGL calls, nor do I need any 3d capabilities. I just want to embed a QWebEngineView
to display dynamic HTML pages. I'm guessing this should be possible since Chrome works on the same VM without an issue.
推荐答案
我认为没有OpenGL
不能使用Qt WebEngine.在文档中并没有非常明确地说明这一点,但这是我从发现的内容中所了解的.
I don't think there is a way to use the Qt WebEngine without OpenGL
. It is not very explicitly said in the documentation, but here's what I understood from what I found.
这里,QtWebEngine将Chrome的快速移动Web功能集成到了Qt中.另外,Chromium允许通过Qt Quick场景图操纵OpenGL(源代码):
As it is said here, QtWebEngine integrates chromium's fast moving web capabilities into Qt. Plus, it is Chromium that allows the manipulation of OpenGL via the Qt Quick scene graph (source) :
也有人说,渲染过程和GUI过程都应该共享OpenGL上下文:
It is also said that both the render process and the GUI process should share an OpenGL context :
关于Qt WebEngine本身
我们只是讨论了Qt的GUI:实际上,Qt WebEngine不依赖于此GUI(页面渲染和JavaScript执行从GUI进程分离到Qt WebEngine进程中),但是请记住,如果您想要应用程序要工作,您将需要在两个进程之间共享一个OpenGL上下文.特别是,默认情况下,这是通过 QSurfaceFormat 实现的,该文件的可通过功能 QSurfaceFormat :: profile()访问.现在,我们回顾一下 Qt WebEngine平台注释,其中指出:
About the Qt WebEngine itself
We just talked about the Qt's GUI : in fact, the Qt WebEngine is not dependent of this GUI (page rendering and JavaScript execution are separated from the GUI process into the Qt WebEngine process), but remember that if you want your application to work, you will need to share an OpenGL context between both processes. In particular, this is achieved by default with a QSurfaceFormat, which has a OpenGLContextProfile
accessible by the function QSurfaceFormat::profile(). Now, we look back at the Qt WebEngine platform notes which states :
在OS X上,如果在应用程序之后设置了默认QSurfaceFormat 实例,应用程序将以qFatal()退出,并显示一条消息 应在应用程序之前设置默认的QSurfaceFormat 实例.
On OS X, if the default QSurfaceFormat is set after the application instance, the application will exit with qFatal(), and print a message that the default QSurfaceFormat should be set before the application instance.
如果我们看一下Qt的源代码,则OpenGL
的调用是在几个重要文件中进行的,例如qtwebengine\src\core\web_engine_context.cpp
或qtwebengine\src\webengine\api\qtwebengineglobal.cpp
.此外,我还在qtwebengine\src\3rdparty\chromium\
的源代码中找到了对OpenGL
的调用,因此我怀疑Chromium有时需要调用OpenGL函数.
If we look at the source code of Qt, calls to OpenGL
are made in several important files, like qtwebengine\src\core\web_engine_context.cpp
or qtwebengine\src\webengine\api\qtwebengineglobal.cpp
. Moreover, I also found calls to OpenGL
in functions from the sources in qtwebengine\src\3rdparty\chromium\
, so I suspect that Chromium needs to call OpenGL functions sometimes.
Qt WebEngine使用Chromium(不一定使用OpenGL)以及Qt GUI,Qt GUI使用必须由Web Engine共享的OpenGL
上下文.因此,我的结论是,没有OpenGL,您将无法使用Qt WebEngine.
The Qt WebEngine is using Chromium (which doesn't necessarily use OpenGL) and also Qt GUI, which uses an OpenGL
context which has to be shared by the Web Engine. Thus, my conclusion is that you can't use the Qt WebEngine without OpenGL.
这篇关于有什么方法可以在不使用OpenGL的情况下使用QtWebEngine?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!