01-21-2013 09:54 PM
hello , i dont find a solution to add many items in my list using qml ,
if someone can help me please??
my obgective to create a list using only qml and i can put at each item a picture. i'm using dataModel: ArrayDataModel but i cant put him a picture.
thanks for help.
listItemComponents: ListItemComponent {
id: dd
StandardListItem {
title: "dd"
description: "d"
imageSpaceReserved: true
imageSource: "asset:///images/ev.png"
}
}
01-22-2013 12:56 AM
01-22-2013 01:15 AM
thanks, but i prefer to use ListView without xml file, beacause I get Data from my data base in my server and i must fetch the table in the same time i fill my ListView.
01-22-2013 05:45 PM
What you've posted should work as it is, if your assets folder has the defined image.
So perhaps you must give us more context on your problem?
01-22-2013 09:08 PM
Hi , this is my file
import bb.cascades 1.0
import Network.RequestHeadersElectro 1.0
import "controls"
import my.library 1.0
/**
* This is a simple Page that allows you to get the HTTP reqeust headers from a newtwork request
*
* You will learn how to:
* -- Import C++ objects
* -- Use attachedObjects
* -- Use a QTimer for timing operations
**/
Page {
property string val: ""
property string ss: "";
property string ligne: "";
// property int i: 0;
Container {
layout: DockLayout {
}
// The background image
ImageView {
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill
imageSource: "asset:///images/bgg11.png"
}
Label {
id:lab
text:""
visible: false
}
//! [0]
Container {
ImageView {
imageSource: "asset:///images/el.png"
minHeight: 100
minWidth: 800
}
}
Container {
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Center
leftPadding: 50
TextArea {
id: headers
visible: false
editable: false
backgroundVisible: false
text: qsTr(" Please wait")
textStyle {
base: SystemDefaults.TextStyles.BodyText
color: Color.White
}
}
}
NetworkActivity {
id: progressIndicator
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill
title: qsTr(" Please wait")
}
attachedObjects: [
QTimer {
id: timer
interval: 1000
onTimeout: {
netheaders.getRequest();
}
},
ComponentDefinition {
},
RequestHeadersElectro {
id: netheaders
onComplete: {
progressIndicator.active = false;
progressIndicator.visible = false;
theDataModel1.clear()
theDataModel1.append(info.split(': '));
for (i = 0; i < theDataModel1.size(); i ++) {
val = info.split(': ')[i];
val = val.split(' *** ')[0];
theDataModel1.replace(i, val);
// ss=ss+"-"+val;
}
theDataModel1.removeAt(0);
theDataModel1.removeAt(theDataModel1.size() - 1);
for (i = 0; i < theDataModel1.size(); i ++) {
val = theDataModel1.value(i);
val = val.split('///')[1]+" ("+val.split('///')[8]+")";
theDataModel1.replace(i, val);
// ss=ss+"-"+val;
}
//------------------------------------------------
///////////////////HEADER///////////////////////
headers.text = "";
var i;
ss = "";
for (i = 0; i <= theDataModel1.size(); i ++) {
val = info.split(': ')[i];
val = val.split(' *** ')[0];
ss = ss + "---" + val;
}
ligne = ss.split('A---')[1];
////////////////////////////////////////
// headers.text=ligne;
///////////////////////////////////
// headers.text = info;
headers.visible = true;
timer.stop();
}
}
]
ListView {
id: appList
translationY: 100
property variant selectedPath: [
]
listItemComponents: ListItemComponent {
/* StandardListItem {
* title: "dd"
* description: "d"
*
* // imageSpaceReserved: true
* }*/
}
dataModel: ArrayDataModel {
id: theDataModel1
property int item_count: 0
function update_count() {
item_count = size();
}
onItemAdded: update_count()
onItemRemoved: update_count()
onItem_countChanged: update_count()
}
onSelectionChanged: {
if (selected) {
selectedPath = indexPath;
} else selectedPath = [];
}
onTriggered: {
clearSelection();
select(indexPath, true);
var z=Number(indexPath+"");
// theDataModel1.replace(2, z);
var ligneRecuperer=ligne;
ligneRecuperer= ligneRecuperer.split('---')[z];
// theDataModel1.replace(2, ligneRecuperer);
lab.text=ligneRecuperer;
// httpGetNavPane.push(ipInfoPageDefinition.createObj
navigationPane.push(ipInfoPageDefinition.createObj
}
onCreationCompleted: {
// theDataModel1.append(["400","500", "600", "400","700", "400", "500", "700", "600", "700", "500", "600"]);
}
}
onCreationCompleted: {
progressIndicator.active = true;
timer.start();
theDataModel1.clear();
}
//! [0]
}
}
01-22-2013 09:14 PM
my file work well and my list is well to , but i used
listItemComponents: ListItemComponent {
/* StandardListItem {
* title: "dd"
* description: "d"
*
* // imageSpaceReserved: truee
* }*/
}
the model to add a image for exemple or a tite or descreption on my list,my list become contains only one line
if can i resolve this problem, i would have a list contains fhotos and title devlopped with qml and without xml file , beacause a use a server , thks