我有一个使用 Qt WebEngine 的应用程序。但我发现在关闭我的应用程序或崩溃后,“Qtwebengineprocess”仍然存在。我的应用太大,无法在此处显示,但这里有一个小示例也可以说明问题:
#include <QApplication>
#include <QWebEngineView>
#include <QProcess>
#include <QTimer>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QWebEngineView* viewer = new QWebEngineView(NULL);
viewer->show();
viewer->load(QUrl("https://www.telegraph.co.uk/content/dam/Pets/spark/royal-canin/tabby-kitten-small.jpg?imwidth=1400"));
QTimer::singleShot(2000, []() {
exit(-1);
});
app.exec();
delete viewer;
return 0;
}
我是不是忘了设置一些东西?或者这是一个 Qt 错误?提前致谢。
更新:Qt 5.11、Win10
最佳答案
我找到了实际问题和解决方案 - here .这是 Qt 5.11 错误,正是描述了这个问题。
其中一条评论有对我有用的解决方案:
When running with QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
at the top of the main() function, I'm observing that the qtwebengine process closes correctly,
both when stopping the debugger and when the release exe crashes.
刚刚在创建我的 qApp
之前添加了该行,没有发现任何崩溃。当然,这伴随着在 Qt 上使用 ANGLE 与动态 GPU 的优点和缺点,more details here .
关于c++ - Qtwebengine进程在应用程序关闭后没有关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51559002/