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
Regular Contributor
Posts: 83
Registered: ‎07-19-2012
My Device: Bold 9790, Dev Alpha A
My Carrier: Koodo

Re: Will ImageView, ImageTracker support web URLs?

Anyone have any luck yet getting a workout around for this?

Developer
Posts: 102
Registered: ‎06-03-2012
My Device: Playbook
My Carrier: *

Re: Will ImageView, ImageTracker support web URLs?

Well, it a bit of work, but here is what I'm doing.

 

In C++ create a QObject based type, e.g. Person with properties like that:

QString name

QUrl imageUrl

bb::cascades::Image image

 

Implement that once the imageUrl has been changed, the image data should be downloaded using QNetworkAccessManager. Out of the QByteArray construct a bb::cascades::Image. Set it to the image property and emit imageChanged() to notify the UI to redraw the image.

 

Create Person objects and add them to a list model. Export this list model from C++ to QML and bind it there to the ListView.

 

Of course this is a very rough overview, but it might give you an idea. I've got an app implementing this and I'll try to push it to some public place soon. I'll share a link here once it's done (not before the weekend probably).

 

-----------
http://kodira.de
BB Apps: Pattern :: Plonk
Developer
Posts: 102
Registered: ‎06-03-2012
My Device: Playbook
My Carrier: *

Re: Will ImageView, ImageTracker support web URLs?

Developer
Posts: 91
Registered: ‎09-25-2012
My Device: bb10 alpha
My Carrier: free

Re: Will ImageView, ImageTracker support web URLs?

Here is the solution , using my WebImageView : 

https://dl.dropbox.com/u/25981400/web_image_example.zip

 

// Default empty project template
import bb.cascades 1.0
import org.labsquare 1.0
// creates one page with a label
Page {
    Container {
        layout: DockLayout {}
      
          WebImageView {
              url:"http://syvolc.briolet.fr/wp-uploads/2010/11/qt-logo1.jpg"
              }
    }
}

 

How I do : 

 

-subclassing bb::cascade::Image

-create a property named url 

- use QnetworkAccessManager to send and get back the bytearray of the image

- SetImage using the bytearray received

- register my new Element BEFORE  QmlDocument::create("asset:///main.qml").parent(this); The DOC say after... 

- Do not forget to add : QT+= network in your *.pro file

 

Enjoy And Thanks Qt to be cute... And cascade blackberry to be ugly :smileyvery-happy:

 

 

 

a lover of Qt
Developer
Posts: 75
Registered: ‎09-12-2012
My Device: Looking for a BB10 testing device
My Carrier: Developper

Re: Will ImageView, ImageTracker support web URLs?

That is perfect and so usefull ! Thanks a lot for sharing.

---------
Mobile developer freelance - QtQuick - Cascades - WP7 - Android
My works : http://fdelgado.fr
Developer
Posts: 91
Registered: ‎09-25-2012
My Device: bb10 alpha
My Carrier: free

Re: Will ImageView, ImageTracker support web URLs?

I think now , I m going to make the solution to get a model List from the web.
a lover of Qt
Developer
Posts: 102
Registered: ‎06-03-2012
My Device: Playbook
My Carrier: *

Re: Will ImageView, ImageTracker support web URLs?

Thanks for posting this code. Only a few minor remarks (I know it's an example, just for others who want to build on it).

 

1) I think you shouldn't create a QNetworkAccessManager for each image. Instead create a singleton QNetworkAccessManager somewhere and use that for all http requests.

 

2) in WebImageView::imageLoaded() I think you should call reply->deleteLater() to prevent a memory leak.

 

3) A "loading" property is a nice add-on. That way you can display a busy indicator using QML while the image loads.

 

Thanks again!

-----------
http://kodira.de
BB Apps: Pattern :: Plonk
Developer
Posts: 91
Registered: ‎09-25-2012
My Device: bb10 alpha
My Carrier: free

Re: Will ImageView, ImageTracker support web URLs?

Yes totally true! 

 

Here is the improvement: 

 

https://dl.dropbox.com/u/25981400/image_example2.zip

a lover of Qt
Developer
Posts: 91
Registered: ‎09-25-2012
My Device: bb10 alpha
My Carrier: free

Re: Will ImageView, ImageTracker support web URLs?

New update with a loading indicator :

https://dl.dropbox.com/u/25981400/image_example3.zip
a lover of Qt
Developer
Posts: 102
Registered: ‎06-03-2012
My Device: Playbook
My Carrier: *

Re: Will ImageView, ImageTracker support web URLs?

Very nice! Thanks :smileyhappy:
-----------
http://kodira.de
BB Apps: Pattern :: Plonk