分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 软件开发

Qt5.WebView.添加节点的测试代码

发布时间:2023-09-06 02:10责任编辑:傅花花关键词:Web

1、代码:

#include "mainwindow.h"#include "ui_mainwindow.h"#include <QWebFrame>#include <QWebElement>#include <QDebug>MainWindow::MainWindow(QWidget *parent) : ???QMainWindow(parent), ???ui(new Ui::MainWindow){ ???ui->setupUi(this);}MainWindow::~MainWindow(){ ???delete ui;}void MainWindow::on_pbtnOpenSVG_clicked(){ ???ui->webView->load(QUrl::fromLocalFile("D:\\DRGIS\\BIN\\PwDrawSvg\\NewSvg.svg"));}void PatchElement(void *_p){#ifndef DEBUG_ZZ ???_asm ???{ ???????push eax ???????mov eax,_p ???????mov eax,[eax+4] ???????or [eax+0xc],0x10 ???????pop eax ???}#else// DEBUG_ZZ ???_asm ???{ ???????push eax ???????mov eax,_p ???????mov eax,[eax+4] ???????or [eax+0x14],0x10 ???????pop eax ???}#endif// DEBUG_ZZ}void PatchElementUn(void *_p){#ifndef DEBUG_ZZ ???_asm ???{ ???????push eax ???????mov eax,_p ???????mov eax,[eax+4] ???????and [eax+0xc],0xFFFFFFEF ???????pop eax ???}#else// DEBUG_ZZ ???_asm ???{ ???????push eax ???????mov eax,_p ???????mov eax,[eax+4] ???????and [eax+0x14],0xFFFFFFEF ???????pop eax ???}#endif// DEBUG_ZZ}void MainWindow::on_pbtnAppendWebEle_clicked(){ ???QWebElement eleSvg = ui->webView->page()->currentFrame()->documentElement(); ???//qDebug() << eleSvg.tagName(); ???QWebElement eleFind = eleSvg.findFirst("#Term_Layer"); ???if (eleFind.isNull()) ???????qDebug() << "eleFind is Null"; ???else ???????qDebug() << "eleFind is not Null"; ???QString str = "<g id=\"zzz\"></g>";
  // ZC: 下面的 PatchElement()和PatchElementUn(),暂时是在 Release中使用,Debug中不确定一定OK... ???PatchElement(&eleFind);  // ZC: 使用QWebElement::???Inside(...)的时候,就要对 那个节点 进行Patch ! ! ! ???eleFind.appendInside(str); ???PatchElementUn(&eleFind); ???PatchElement(&eleFind.parent());  // ZC: 使用QWebElement::???Outside(...)的时候,就要对 那个节点的父节点 进行Patch ! ! ! ???eleFind.appendOutside(str); ???PatchElementUn(&eleFind.parent());}void MainWindow::on_pbtnPrintSvgContent_clicked(){ ???qDebug() << ui->webView->page()->currentFrame()->toHtml();}

2、

#-------------------------------------------------## Project created by QtCreator 2018-08-15T09:00:45##-------------------------------------------------QT ??????+= core guigreaterThan(QT_MAJOR_VERSION, 4): QT += widgets ????????????????????????????????????????webkit ?????????????????????????????????????????webkitwidgetsTARGET = WebView_Test_01TEMPLATE = appSOURCES += main.cpp ???????mainwindow.cppHEADERS ?+= mainwindow.hFORMS ???+= mainwindow.ui

3、

4、

5、

Qt5.WebView.添加节点的测试代码

原文地址:https://www.cnblogs.com/cppskill/p/9479596.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved