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
Developer
Posts: 102
Registered: ‎04-01-2014
My Device: BlackBerry10 Simulator
My Carrier: none
Accepted Solution

load html code to qml

Hi,

 

what I wanna do is dynamically load html code into webview of an app. Which means I generate some html-code fill it with a string and then put this with certain style-options into the WebView option of qml.

 

I'm new to BlackBerry app development and not sure how to start here. Can anyone give me a hint?

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: load html code to qml

WebView takes a direct text as source code, as well as URLs, so just creating a QString and setting the html property to that QString would suffice.

 

Take a look at this to understand WebView better...

 

http://developer.blackberry.com/native/documentation/cascades/ui/webview/loadingwebcontent.html


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 102
Registered: ‎04-01-2014
My Device: BlackBerry10 Simulator
My Carrier: none

Re: load html code to qml

Thanks for the link.

 

I see I have to describe more precise what I wanna do because in involves C++.

 

What I want to do is generating a C++ class in which I can generate html code. I have read that to use C++ objects in QML you have to use QObjects, define QProperties and to make the function you want to use in qml invokable use Q_INVOKABLE, like described here:

http://developer.blackberry.com/native/documentation/cascades/dev/integrating_cpp_qml/index.html#exp...

 

Now I'm not quite sure how to generate a html-code with this tutorial. And how to make my app read this generated html-code in WebView.

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: load html code to qml

That's a different question really and one that I think needs you to play around with creating your own custom control classes until you understand the concept.

 

However the basics will be;

 

  Create a Class derived from QObject

  Add a QProperty something like myHtml

  Write the dynamic html code in the class

  Expose the class to QML

  Include your library in the QML page

  Add the myHtml property of your QObject class to WebView's html property

 

It probably seems complicated at the start but there are many examples in the samples so I suggest you download a few of those and work through understanding them.

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.