QT控件之c

QWebEngineView类在QWebEngineView模块中,需要在项目.pro文件中添加QWebEngineView模块名

QWebEngineView使用步骤

  • 创建QWebEngineView对象
  • 通过load方法设置QUrl设置访问地址
  • 调用show方法进行显示

一个简单Demo

创建MyWebEngineView继承自QWebEngineView

复制代码
#ifndef MYWEBENGINEVIEW_H
#define MYWEBENGINEVIEW_H

#include <QObject>
#include <QWebEngineView>
#include <QWidget>

class cc
{
    Q_OBJECT
public:
    MyWebEngineView(QWidget* parent = nullptr);
};

#endif // MYWEBENGINEVIEW_H

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

    QVBoxLayout *mainLayout = new QVBoxLayout(this);

    m_webEngineView = new MyWebEngineView(this);
    m_webEngineView->load(QUrl("https://www.baidu.com"));

    mainLayout->addWidget(m_webEngineView);

    setLayout(mainLayout);
}
相关推荐
Quz2 天前
QML Hello World 入门示例
qt
xcyxiner5 天前
DicomViewer (dcmtk读取dcm文件)5
qt
xcyxiner6 天前
DicomViewer (后台线程处理文件)4
qt
xcyxiner6 天前
DicomViewer (添加模型类)3
qt
xcyxiner7 天前
DicomViewer (目录调整) 2
qt
xcyxiner7 天前
dcmtk vtk vtk-dicom(gdcm) 编译(debug) v2
qt
LDR0069 天前
Type-C 快充全面升级!LDR6601 赋能个人护理便携电机,重塑剃须刀 / 理发器新体验
c语言·开发语言
雪碧聊技术9 天前
Tree.js是什么?一文讲透
开发语言·javascript·ecmascript
码云数智-园园9 天前
C++20 Modules 模块详解
java·开发语言·spring
swordbob9 天前
NIO的channel中什么是 fd(File Descriptor,文件描述符)
java·开发语言·nio