English 中文(简体)
Qt Webview 谷歌地图
原标题:Qt Webview Google Maps Caching

我创建了一个 Google 地图部件, 该部件属于 QWebView 子类 。 基本上, 所有谷歌地图都以 Javascript 写入( 使用 Google 的 Javascript API ), 并保存在本地存储的 html 文件中 。 然后, 该部件只显示 html..., 并且做了一些其他的东西, 但是这无关紧要 。

我面临的问题是,地图砖的装入时间要长得多,比我打开相同的 html 文件的时间要长得多, 比如说 Chrome 或 Safari 。 根据 Qt 所使用的相同的 WebKit, 是否是t Chrome 和 Safari?

是否有人遇到类似的情况? 是否有办法隐藏地图牌,这样它就不必每次显示更新时再拉伸它们? 理想的情况是,我想能够永久隐藏它们,这样我的程序可以脱线,但我知道这与谷歌的TOS相悖。 我将满足于能够隐藏这些砖块以加快铺设/拆解速度。

利用QNetworkDiskCache在各种论坛进行搜索,作为一种潜在的解决方案,但似乎没有人能够让这个办法发挥作用。 我只是不明白为什么同样的html/javascript在Chrome和Safari的运行速度比QWebView要快得多。

问题回答

QNetworkDiskCache 与谷歌地图合作良好, 与未启用时相比, 速度有显著改进。 这应该可以把戏 :

QNetworkAccessManager *manager = new QNetworkAccessManager(this);
QNetworkDiskCache *diskCache = new QNetworkDiskCache(this);

diskCache->setCacheDirectory(QCoreApplication::applicationDirPath() + "/cache");
manager->setCache(diskCache);

然后将管理器添加到 WebView 中:

frame->page()->setNetworkAccessManager(manager);
frame->page()->settings()->setMaximumPagesInCache(10);

然后继续上载你的 html 。

frame->setHtml(...);




相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签