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

推荐订阅源

雷峰网
雷峰网
aimingoo的专栏
aimingoo的专栏
云风的 BLOG
云风的 BLOG
Microsoft Security Blog
Microsoft Security Blog
Vercel News
Vercel News
The GitHub Blog
The GitHub Blog
T
The Blog of Author Tim Ferriss
Microsoft Azure Blog
Microsoft Azure Blog
U
Unit 42
IT之家
IT之家
D
DataBreaches.Net
Y
Y Combinator Blog
B
Blog RSS Feed
F
Fortinet All Blogs
GbyAI
GbyAI
V
Visual Studio Blog
博客园 - 叶小钗
Google DeepMind News
Google DeepMind News
美团技术团队
L
LangChain Blog
N
Netflix TechBlog - Medium
G
Google Developers Blog
Recent Announcements
Recent Announcements
T
Tailwind CSS 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)
}
}

}