BB10 Cascades介绍之Image和ImageTracker
2013-06-13 19:02
447 查看
Image和ImageTracker
Image控件负责载入本地图片,包括资源图片和本地路径的图片,它必须是即刻得到且不会失败的。
当然,如果外部图片在本地,可以即刻得到,也可以使用Image控件,需要使用绝对路径并加file://前缀。可能需要借助C++来取得QDir::currentPath路径:
从网络得图片是异步操作,需要在Image中包含ImageTracker,将它的imageSource属性设置为图片地址,并编写onStateChanged事件处理函数,赋值Image.imgae =
参考网页:http://developer.blackberry.com/cascades/documentation/ui/image_resources/index.html
Image控件负责载入本地图片,包括资源图片和本地路径的图片,它必须是即刻得到且不会失败的。
// Absolute path ImageView { imageSource: "asset:///images/myimage.png" } // Relative path ImageView { imageSource: "images/myimage.png" }
当然,如果外部图片在本地,可以即刻得到,也可以使用Image控件,需要使用绝对路径并加file://前缀。可能需要借助C++来取得QDir::currentPath路径:
// ApplicationUI.cpp // Load the QML file QmlDocument *qml = QmlDocument::create("asset:///main.qml"); // Retrieve the path to the app's working directory QString workingDir = QDir::currentPath(); // Build the path, add it as a context property, and expose // it to QML QDeclarativePropertyMap* dirPaths = new QDeclarativePropertyMap; dirPaths->insert("camera", QVariant(QString( "file://" + workingDir + "/shared/camera/"))); qml->setContextProperty("dirPaths", dirPaths); // main.qml // Load the image asynchronously ImageView { imageSource: dirPaths.camera + "camera0001.jpg" }
从网络得图片是异步操作,需要在Image中包含ImageTracker,将它的imageSource属性设置为图片地址,并编写onStateChanged事件处理函数,赋值Image.imgae =
ImageTracker.image: ImageView { id: myImageView attachedObjects: [ ImageTracker { id: tracker imageSource: "images/image.png" onStateChanged: { if (state == ResourceState.Loaded) { myImageView.image = tracker.image } } } ] }
参考网页:http://developer.blackberry.com/cascades/documentation/ui/image_resources/index.html
相关文章推荐
- BB10 Cascades介绍之Image和ImageTracker
- 医学影像处理软件之Image Orientation相关介绍
- BB10 Cascades: 如何为container添加底色和边框
- Matlab图像识别/检索系列(10)—开源介绍之图像检索caltech-image-search
- Cordova各个插件使用介绍系列(三)—$cordovaImagePicker从手机图库选择多张图片
- 【Facebook的UI开发框架React入门之八】Image的使用简单介绍(iOS平台)-goodmao
- imageView属性介绍
- ios中的GpuImage及相关滤镜介绍
- andriod ImageView scaleType个属性全面介绍
- VelocityTracker简单介绍
- ImageGear for .NET免费下载地址用法功能介绍大全
- Android - 控件(View)之TextView, Button, ImageButton, ImageView, CheckBox, RadioButton, AnalogClock, DigitalClock 的简单介绍
- ImageLoader介绍2
- 李洪强详细介绍SDWebImage
- Universal-Image-Loader(UIL)图片加载框架使用简单介绍
- VelocityTracker简单介绍
- js预载入和JavaScript Image()对象使用介绍
- A Detailed Review of Feature Extraction in Image Processing Systems图像处理系统中特征提取的详细介绍
- 海量影像快速发布(一)image Server介绍
- 滑动动速度跟踪类VelocityTracker介绍