惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
Apple Machine Learning Research
Apple Machine Learning Research
IT之家
IT之家
阮一峰的网络日志
阮一峰的网络日志
雷峰网
雷峰网
S
SegmentFault 最新的问题
量子位
有赞技术团队
有赞技术团队
V
V2EX
宝玉的分享
宝玉的分享
Hugging Face - Blog
Hugging Face - Blog
B
Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Jina AI
Jina AI
C
Check Point Blog
G
Google Developers Blog
博客园 - 叶小钗
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园_首页
T
Tailwind CSS Blog
B
Blog RSS Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
酷 壳 – CoolShell
酷 壳 – CoolShell
U
Unit 42

博客园 - 蚂蚁跳楼

博文阅读密码验证 - 博客园 qt 的视频教程 sed 使用 qt dbus 的一入门文章 qt越来越好了 ubuntu - 中文 qt-creator astyle Peizhi 捷豹汽车的车载系统 博文阅读密码验证 - 博客园 转一个文章:在腾讯的第一堂产品课 QML的一些基础的区分 qml的一个文章----可以看出状态、动画的使用 博文阅读密码验证 - 博客园 凡是人性的,都是如下的 全国经纬度,具体到县 web-nodkit 入门 一个文章-转年收入50万美元的软件工程师做的是什么类型的工作 qml 封装技巧-利用数据来进行适配 一个基于qml的网络封装库
qml中打开本地html
蚂蚁跳楼 · 2015-07-27 · via 博客园 - 蚂蚁跳楼

main.cpp

QString tmploc = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
QDir tmpdir(tmploc + "/my_little_project");

QDirIterator it(":", QDirIterator::Subdirectories);
bool isHtml = false;
while (it.hasNext())
{
QString tmpfile;
tmpfile = it.next();
isHtml = tmpfile.contains("html",Qt::CaseInsensitive);
if (QFileInfo(tmpfile).isFile() && (isHtml) )
{
QFileInfo file = QFileInfo(tmpdir.absolutePath() + tmpfile.right(tmpfile.size()-1));
file.dir().mkpath("."); // create full path if necessary
QFile::remove(file.absoluteFilePath()); // remove previous file to make sure we have the latest version
QFile::copy(tmpfile, file.absoluteFilePath());
break;
}
}
ctxt->setContextProperty(QStringLiteral("baseUrl"), QFileInfo(tmpdir.absolutePath() + "/index1.html").absoluteFilePath());

web.qml中
//import QtQuick 2.0
import QtQuick 2.2
import QtQuick.Layouts 1.1
import QtQuick.Controls 1.2 as QuickControls
import QtWebView 1.0

Item{
signal changeUrl(string msg)
property string webParams
property alias weburl: mywebview.url
WebView{
id:mywebview
width:parent.width
height: parent.height
// url: baseUrl
// url:"file:///storage/sdcard0/my_little_project/index1.html"
url:"file:///"+baseUrl //这里必须这么写,否则有问题
onUrlChanged: {
changeUrl(mywebview.url+"")
webParams = mywebview.url
console.log("~~~~~~~~~~url:"+baseUrl)
}
}

}