QWebEnginePage异常CPU使用率

时间:2016-09-05 17:51:48

标签: c++ qt5 cpu-usage windows-7-x64 qtwebengine

在带有Qt 5.6.1的Windows 7专业版x64上,仅此一行就可以使我的CPU达到10-15%:

QWebEnginePage *page = new QWebEnginePage(this);

稍后(甚至立即)删除页面无助于将我的应用程序的使用率恢复到0-1%。任何想法该怎么做?

  

导致问题的完整代码:

problem.pro

QT       += core gui webenginewidgets

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = problem
TEMPLATE = app


SOURCES += main.cpp\
        MainWindow.cpp

HEADERS  += MainWindow.h

FORMS    += MainWindow.ui

problem.h

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QWebEnginePage>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private:
    Ui::MainWindow *ui;
};

#endif // MAINWINDOW_H

problem.cpp

#include "MainWindow.h"
#include "ui_MainWindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    // Comment the next line to reduce CPU usage back to normal
    QWebEnginePage *page = new QWebEnginePage(this);

}

MainWindow::~MainWindow()
{
    delete ui;
}

1 个答案:

答案 0 :(得分:0)

使用 QNetworkAccessManager ,我可以获得与QWebEnginePage相同的结果,但没有不必要的CPU使用率。