QWebEnginePage异常CPU用法
QWebEnginePage abnormal CPU usage
在带有 Qt 5.6.1 的 windows 7 pro x64 上,仅此行就使我的 CPU 达到 10-15%:
QWebEnginePage *page = new QWebEnginePage(this);
稍后(甚至立即)删除 页面 无助于将我的应用程序的使用率降低回 0-1%。有什么想法吗?
Full code causing the problem:
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;
}
使用 QNetworkAccessManager 我能够获得与使用 QWebEnginePage 相同的结果,但没有不必要的 CPU 用法。
在带有 Qt 5.6.1 的 windows 7 pro x64 上,仅此行就使我的 CPU 达到 10-15%:
QWebEnginePage *page = new QWebEnginePage(this);
稍后(甚至立即)删除 页面 无助于将我的应用程序的使用率降低回 0-1%。有什么想法吗?
Full code causing the problem:
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;
}
使用 QNetworkAccessManager 我能够获得与使用 QWebEnginePage 相同的结果,但没有不必要的 CPU 用法。