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

推荐订阅源

Martin Fowler
Martin Fowler
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
IT之家
IT之家
美团技术团队
酷 壳 – CoolShell
酷 壳 – CoolShell
Y
Y Combinator Blog
T
Tailwind CSS Blog
D
Docker
博客园 - Franky
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Google DeepMind News
Google DeepMind News
腾讯CDC
Vercel News
Vercel News
Engineering at Meta
Engineering at Meta
U
Unit 42
The Cloudflare Blog
S
SegmentFault 最新的问题
WordPress大学
WordPress大学
爱范儿
爱范儿
Recent Announcements
Recent Announcements
博客园 - 聂微东
博客园 - 叶小钗
H
Help Net Security
MyScale Blog
MyScale Blog

博客园 - 蚂蚁跳楼

博文阅读密码验证 - 博客园 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)
}
}

}