Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Trusted Contributor
marcelnijman
Posts: 118
Registered: ‎06-19-2012
My Device: PlayBook + Red Z10 + BB10 Dev Alpha C
Accepted Solution

url of assets folder

Hi, what is the QUrl of the assets folder? I need this for WebView::setHtml() so that the webview can access my image resources.

Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: url of assets folder

I believe if you've got .qml in the assets folder, and include a WebView component, the "url" property of the WebView will by default look for files relative to the location of the including file.

I have a file here, assets/CanvasChartTest.qml, which has a WebView { url: "chart.html" }. The file included is at assets/chart.html.

If you needed a path from the current directory for some reason, it would be at "app/native/assets" for the typical Cascades app.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Trusted Contributor
marcelnijman
Posts: 118
Registered: ‎06-19-2012
My Device: PlayBook + Red Z10 + BB10 Dev Alpha C

Re: url of assets folder

I do everything form C. Simpy using QUrl::fromLocalFile("app/native/assets") doesn't work.

Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: url of assets folder

The information I gave is correct, so perhaps QUrl does not take paths as being relative to the current directory of the process, but rather maybe of the location of the binary executable, or some other convention. Have you checked any of the Qt docs to see what it does?

For the platform itself (i.e. not Qt), this has some background for you: http://developer.blackberry.com/native/beta/documentation/com.qnx.doc.native_sdk.devguide/com.qnx.do...

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Trusted Contributor
marcelnijman
Posts: 118
Registered: ‎06-19-2012
My Device: PlayBook + Red Z10 + BB10 Dev Alpha C

Re: url of assets folder

Bingo, I missed a trailing slash.

Here's my solution:

 

QFileInfo fileInfo("./app/native/assets/");

QString s = fileInfo.absoluteFilePath();

QUrl url = QUrl::fromLocalFile(s);

webView->setHtml(string, url);