首页 > 其他分享 >qt使用webengine加载web页面

qt使用webengine加载web页面

时间:2022-10-09 19:39:14浏览次数:45  
标签:web qt mainwindow QT ui webengine include MainWindow view


#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QUrl>
#include <QtWebEngineWidgets/QWebEngineView>

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

QWebEngineView *view = new QWebEngineView(this);
// view->load(QUrl("http://localhost:8080/"));
view->load(QUrl("file:///E:/workspace/vue-space/vue-app01/dist/index.html"));
view->show();
view->resize(this->width(),this->height());
}

MainWindow::~MainWindow()
{
delete ui;
}
QT       += core gui webenginewidgets

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++17

# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
main.cpp \
mainwindow.cpp

HEADERS += \
mainwindow.h

FORMS += \
mainwindow.ui

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS +=


标签:web,qt,mainwindow,QT,ui,webengine,include,MainWindow,view
From: https://blog.51cto.com/u_12836588/5741175

相关文章

  • qt 可执行程序 打包 安装程序
    ​​https://subingwen.cn/qt/qt-setup/#1-2-%E5%8F%91%E5%B8%83​​......
  • pyqtgraph 内嵌到 Qtdesigner 设计界面中
    fromPySide6.QtWidgetsimportQApplication,QMainWindow,QWidgetimportpyqtgraphaspgimportsysfromPySide6importQtCore,QtWidgetsimportnumpyasnpfrom......
  • qt 设置程序的图标
    创建一个ico图标,拷贝到程序根目录修改程序配置文件xxx.pro...RC_ICONS=app.ico重新发布即可!......
  • javaweb文件上传和下载
    案例1:文件随同表单一起上传前端页面<div><formclass="form-signin"id="addSongFormId"enctype="multipart/form-data"method="post">歌曲:<inputtype="file"id="fileS......
  • Qt最基本的布局,创建window界面
    #include"mainwindow.h"#include<QMenuBar>#include<QToolBar>#include<QStatusBar>#include<QLabel>#include<QDockWidget>#include<QTextEdit>MainWindow::MainWin......
  • qt 回车事件之Qt::Key_Return与Qt::Key_Enter
    这两个都得包含限制!缺一个不行。Key_Enter是小键盘的确认键,Key_Return是大键盘的回车键。voidWidget::keyPressEvent(QKeyEvent*ev){if(ev->key()==Qt::Key_Enter|......
  • mac 下qt程序添加程序图标
    第一步桌面新建一个文件夹,命名为logo.iconset。将png图标(原图只能是.png文件)放进去。第二步:打开终端,cd到这个文件夹,依次执行下面的语句:sips-z1616logo.png--outicon_......
  • qt 设置图标
    #include"mainwindow.h"#include"ui_mainwindow.h"MainWindow::MainWindow(QWidget*parent):QMainWindow(parent),ui(newUi::MainWindow){ui->setupUi(th......
  • pyside6 webengine
    importsysfromPySide6.QtWidgetsimportQApplication,QWidget,QVBoxLayout,QMainWindow,QLabel,QPushButtonfromPySide6importQtCorefromPySide6.QtWebEngineWi......
  • 智能合约web3.0系统开发实现核心
     Web3就是一个去中心化的互联网,旨在打造出一个全新的合约系统,并颠覆个人和机构达成协议的方式。Web3复刻了第一版互联网(即Web1.0)的去中心化基础架构,Web1.0的特色是用户......