10-03-2012 10:58 PM
Anyone have any luck yet getting a workout around for this?
10-04-2012 01:13 AM
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).
10-04-2012 02:21 AM
Also please consider voting for those JIRA items:
https://www.blackberry.com/jira/browse/BBTEN-270
https://www.blackberry.com/jira/browse/BBTEN-271
https://www.blackberry.com/jira/browse/BBTEN-272
10-04-2012 06:48 AM
Here is the solution , using my WebImageView :
https://dl.dropbox.com/u/25981400/web_image_exampl
// 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-log o1.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").p
- Do not forget to add : QT+= network in your *.pro file
Enjoy And Thanks Qt to be cute... And cascade blackberry to be ugly ![]()
10-04-2012 07:28 AM
That is perfect and so usefull ! Thanks a lot for sharing.
10-04-2012 07:30 AM
10-04-2012 08:25 AM
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!
10-04-2012 08:33 AM
Yes totally true!
Here is the improvement:
https://dl.dropbox.com/u/25981400/image_example2.z
10-04-2012 09:03 AM
10-04-2012 10:02 AM