c++ - Qtwebengine进程在应用程序关闭后没有关闭

标签 c++ qt qtwebengine

我有一个使用 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/

相关文章:

c++ - rand() 真的会这么糟糕吗?

c++ - QFileSystemModel如何将RootPath设置为linux上的另一个驱动器

qt - 如何本地化 Qt qmldir 插件?

javascript - qt webengine 将 javascript 输出重定向到 GUI

c++ - Qt WebEngine 打印时不正确的页边距

c++ - 每次循环初始化一个 vector

c++ - 动态创建的 Activex 控件的事件处理

c++ - C++如何将纸牌游戏中的纸牌相加?

c++ - vim c++ 模板编写

c++ - 在 QTabWidget 中嵌入一个 QWebEngineView 进程