【发布时间】:2016-09-05 17:51:47
【问题描述】:
在带有 Qt 5.6.1 的 windows 7 pro 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;
}
【问题讨论】:
标签: c++ qt5 cpu-usage windows-7-x64 qtwebengine