QWebEngineView介绍
添加库
QT += core gui webenginewidgets
出现问题
解决
提升类
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
//ui->web_widget->load(QUrl("http://www.baidu.com"));
ui->web_widget->setUrl(QUrl("http://www.baidu.com"));
ui->web_widget->show();
}
本地页面
QString localUrl = "D:/testvideo/youku_video_html/index.html";
//localUrl = QDir::toNativeSeparators(localUrl);
ui->web_widget->setUrl(QUrl(localUrl));
ui->web_widget->show();
写一个类的方法
#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
QString localUrl = "D:/testvideo/youku_video_html/index.html";
//localUrl = QDir::toNativeSeparators(localUrl);
ui->web_widget->setUrl(QUrl(localUrl));
ui->web_widget->show();
// m_pCWebView = new CWebView(this);//E:\ljl\pro\qt\240711\1123\widget.ui:-1: warning: The name 'layoutWidget' (QWidget) is already in use, defaulting to 'layoutWidget1'.
ui->widget->load(QUrl("http://www.baidu.com"));
ui->widget->show();
}
Widget::~Widget()
{
delete ui;
}