QML ListView

Hello people!

I'm developing an application in which I use a ListView filled by an XML file (as for now), but I want to make entries bigger and maybe even a little cloroful. Found nothing about that.

Any help?

Wildcat

ListView {

  listItemComponents: [
      ListItemComponent {
          type: "item"

          CustomListItem {
              Label{
                  text: ListItemData.title
              }
          }
      }
  ]
}

CustomListItem (or something like that), you should get what you want. Instead of the label, you can use container and put in as much as you want

Tags: BlackBerry Developers

Similar Questions

  • Complete ArrayDataModel QML and filling data in ListView

    Hello

    the filepicker, I get the file + the path to a file. Now I extracted the path and the name of the file to the string «selectedFile»

    Now, I want to add these two channels to an ArrayDataModel, which displays the data in a listview, the file name as the title and filepath as description.

    Here is my code:

    // Main.qml
    
    ListView {
      id: listview
    
      dataModel: ArrayDataModel {
        id: theDataModel
      }
    
      listItemComponents: [
        ListItemComponent {
    
          StandardListItem {
    
             title: ListItemData   <------------------ here I want to display the filename
             description: "filepath"   <-------------- and here I want to display the filepath
             imageSource: "asset:///images/icon.png"
    
    [...]
    
    onFileSelected: {  selectedFile = selectedFiles[0];  [...]    var filepath = *a string*    var filename = *a string*    theDataModel.append([filename, filepath]); <-------------- how can I add the two strings correctly to the datamodel?}
    

    What my code for the time when I take a file is that it adds two items to the list the first file name as title the second filepath as a title.

    How to manage to give the file name-path to the datamodel so that I can read both of them and put them in the view list?

    // Main.qml
    
    ListView {
      id: listview
    
      dataModel: ArrayDataModel {
        id: theDataModel
      }
    
      listItemComponents: [
        ListItemComponent {
    
          StandardListItem {
    
             title: ListItemData.name       <---------------------------------------------------|
             description: ListItemData.path  <-----------------------------------------------|
             imageSource: "asset:///images/icon.png"                                              |
                                                                                                                            |
    [...]                                                                                                                  |
                                                                                                                            |
    onFileSelected: {                                                                                             |
      selectedFile = selectedFiles[0];                                                                     |
      [...]                                                                                                                |
        var filepath = *a string*                                                                              |
        var filename = *a string*                                                                            |
        theDataModel.append([filename, filepath]); <----------- how do I add the strings correctly so that I can us them in the list
    }
    

    Hello!

    For the arrayDataModel, I suggest you use this

    data var = {}
    'name': name of file,.
    'path': filepath
    }

    theDataModel.append (data);

    If you still have a problem, let me know!

    Simon

  • ListView with custom headers (sections)

    Hello

    I need custom headers (basically something like sections QML native ListView component http://doc.qt.nokia.com/4.7-snapshot/qml-listview.html#section.criteria-prop) in my ListView. In my case, I have list of comments that I want to be sorted by DateTime and contain headers: «Today, yesterday, last 7 days, Older» Source of ListView is GroupDataModel (QVariantList of SqlDataAccess).

    Any ideas?

    Thank you

    Jan

    As far as I'm concerned, I think that's not possible!

    Likewise, you cannot sort on key on a second key in DESC and ASC.

    In addition, the title of the header section is the value used to sort data

    So in anticipation, I add a prefix to my field in the QML and sort, I have re - format text.

    In your case, I do "1-Today", "2-Yesterday", "3-Last..." » ; then I sort on this key. and I don't value.substring (...) in QML

    To remove my prefix.

    Nicolas

  • Create a localized ListView

    Hi, I created a custom in QML ListView that retrieves

    data from XML (has an XML file as a data model).

    I think I know how to support the chain located in typical situations,

    for example, in QML I add qsTr keyword strings that i want to be

    translated into different languages.

    But how to do the same thing with the XML data source?

    Thank you.

    There are several options;

    (1) use qrTr in your QML file by passing the returned ListDataItem.xxx

    (2) provide a translation in the XML file as a separate field.

    (3) providing an additional XML file for each language you want to support then load the appropriate.

    You might find 3 is the easiest to maintain go before there is an obvious leaking between the XML file and any file translation which, without adequate testing, could lead to missed translations. that is any text that you place in your xml file is not automatically picked up by collection of translation to the compilation service.

  • ListView cannot see C++ object passed to QML via QmlDocument-&gt; setContextProperty()

    I can access a C++ object using the QmlDocument function-> setContextProperty() in JavaScript inside most of the QML elements (such as containers, ImageButton, control etc.) happened, but can't access it from the JavaScript inside ListView. I get "ReferenceError: can't find variable: app. Why is this?

    Why is it a "problem"? It's probably just the way things work and should work. ListItemComponents are not really part of the scene graph/context since they exist only to be used during execution. Wait so the scope of the listItemcomponent unlike the rest of the document.

    The way around it, as described in the thread linked above is to create a function inside your listview that refers to the context property that you want to use. Then, your listitemcomponent has access to this feature of the listview.

  • How to get the item to the index by the listview in qml programming

    Hi guys.

    I'm sorry my English not good level.

    At the point of selection Android listview to index easylly, I call ListView.selectionPosition (int index)

    But when you use ListView on cascades qml, I think point get in way to the index.

    Hope you help me.

    For a simple DataModel with a single level of items, you can access the item at a specific position with code of God:
    int position = 0
    var MonElement = myDataModel.data ([position])-requires one [of QVariantList]

  • What do you see when you run that this basic example ListView QML?

    I read through the examples of ListView found here:

    http://developer.BlackBerry.com/native/reference/Cascades/bb__cascades__ListView.html

    I'm at the part that speaks of "'How to create a list in QML and access a variable inside the ListView". " When I run the example, I see a ListView display the data I entered model.xml.    But must I also see "Example text" added on each entry in ListView?    I don't see "Example text" displayed anywhere.

    The property type must match the xml in the template tag, for example:

    Using this model in xml format:

    
      

    With this qml code works perfectly:

    import bb.cascades 1.3
    
    Page {
        ListView {
            property string myText: "is a City"
            dataModel: XmlDataModel {
                source: "model.xml"
            }
            listItemComponents: [
                ListItemComponent {
                    type: "item"
                    CustomListItem {
                        id: itemRoot
                        dividerVisible: true
                        highlightAppearance: HighlightAppearance.Full
                        Container {
                            Label {
                                text: ListItemData.title + " " + itemRoot.ListItem.view.myText
                            }
                        }
                    }
                }
            ]
        }
    }
    
  • number of lines in the ListView blackberry stunts QML

    Hi all

    I have a ListView in QML page that contains several elements.

    I also want to display the total number of lines on the bottom of the page.

    Please tell me how.

    View the list code is as below: -.

     //! [1]
                    // The list view with all messages
                    ListView {
                        dataModel: _messages.model
    
                        listItemComponents: ListItemComponent {
                            type: "item"
    
                            StandardListItem {
                                title: ListItemData.senderName
                                description: ListItemData.sender
                                status: ListItemData.time
                            }
                        }
    
                        onTriggered: {
                            clearSelection()
                            select(indexPath)
    
                            _messages.setCurrentMessage(indexPath)
    
                            _messages.viewMessage();
                            navigationPane.push(messageViewer.createObject())
                        }
                    }
                    //! [1]
    

    Please suggest

    call on the datamodel size()

  • Access CPP of the ListView in QML function

    ListView {
                id: listView
                dataModel: dataModel
                listItemComponents: [
                    ListItemComponent {
                        type: "item"
                        StandardListItem {
                            title: ListItemData.title
                            description: app.formatDate(ListItemData.pubDate);
                        }
                    }
             ]
    }
    

    and in the PRC

    QString ApplicationUI::formatDate(QString date) {
        return "bla";
    }
    

    Function call leave outer ListView works well, but I cannot access any function defined outside ListView!

    In this case, I get asset:///blabla.qml:16: ReferenceError: can't find variable: app

    How can I call it?

    For some strange reason the listItemComponents are outside the normal code flow. But you can bypass. Give your listItemComponent a name/id. You can reference it trough the parent ListView. Something like this should work:

    StandardListItem {
     id: mscurli
     title: ListItemData.OriginalTitle;
     description: ListItemData.TheatreAndAuditorium
     status: mscurli.ListItem.view.getShowTime(ListItemData.dttmShowStart);
    }
    

    I used a set inside my ListView simple helper function to get the C++ code:

    function getShowTime(str) {
     return _myapp.formatTime(str);
    }
    
  • Fill ListView C++ QML

    Hello!

    I created interface using QML. I have a ListView but I want add data by using c++.

    I guess, the easiest is to send ListView pointer as an argument to the function c ++. I'm trying to do something like that.

    QML

    Page {
        Container {
            Label {
                // Localized text with the dynamic translation and locale updates support
                text: qsTr("Hello World") + Retranslate.onLocaleOrLanguageChanged
                textStyle.base: SystemDefaults.TextStyles.BigText
            }
            ListView {
                id: contacts_lw;
            }
        }
        onCreationCompleted: {
            app.fillListView(contacts_lw);
        }
    }
    

    C++ Builder

    qml->setContextProperty("app", this);
    

    function

    Q_INVOKABLE void ApplicationUI::fillListView(ListView & lw)
    {
        GroupDataModel *model = new GroupDataModel(QStringList() << "first_name" << "last_name");
    
       JsonDataAccess jda;
       QVariantMap jsonmap = jda.load(QDir::currentPath() +
                    "/app/native/assets/contacts.json").toMap();
    
       QVariantList list = jsonmap["response"].toList();
    
       model->insertList(list);
    
       lw->setDataModel(model);
    }
    

    How to make it work?

    use a pointer, not a reference as a parameter.
    If ListView is unknown as a parameter, you can either use qmlRegisterObject to publicize or use a QObject * as a parameter and cast him.

  • Remove items from the ListView to a ContextAction in QML?

    Is it possible to delete a list in qml item triggered by an action of context? I tried to do in signal of onTriggered of the ActionItem of all actions in context, but it seems that I can not even access my ListView by its id.

    Inside of a list component should be possible to remove it by

    myItemRoot.ListItem.view.dataModel.removeAt( myItemRoot.ListItem.indexPath );
    

    Inside of the OnTriggered could be:

    listView.dataModel.removeAt( indexPath );
    
  • How get the number of items in the ListView inside QML?

    QML/JavaScript newbe question here please.

    Suppose I have .qml

    import bb.cascades 1.0
    
    NavigationPane {
        id: navigationPane
        Page {
    ...
            Container {
    ...
                  ListView {
                        id: listviewPlayers
    ...
    

    and I want to do something if ListView does contain all of the elements

        onCreationCompleted: {
            // this slot is called when declarative scene is created
            if (listviewPlayers.AllItems.count() == 0){
                // do something;
            }
    

    but when I run the present I get complain AllItems is not defined in this line:

     if (listviewPlayers.AllItems.count() == 0){
    

    What I doing wron? I can do the same thing in C++ without any problem.

    Thank you.

    Oh, this thing AllItems seems to be a 'Sentinel' or a magic value used in special cases, unrelated to this.

    I think that ListView manages all this, but defers everything to do with the pieces of data to the model, you don't have to go to the model for the data. ListView knows how VisualNodes (the components list item) he created at the time of the display on the screen, but also have to tell you the total number of elements in the model would simply duplicate work. (The reasoning behind this interpretant.)

  • How to show my listview QML this JSON webservice

    Hi all

    IM new developer for blackberry 10

    It's my first project of construction of a PSA

    I want to ask

    1. This is my JSON www.rws.rajaspot.com/rs_promoclient.php

    2. I want to do a listview in my QML using this JSON

    y at - it a code for this example, I tried to make the market http://stackoverflow.com/questions/18598886/how-to-use-json-webservice-in-blackberry-cascades and http://stackoverflow.com/questions/18638067/how-to-create-listview-for-json-parsing-in-blackberry-ca... but still get error

    Please help, thanks

    Did you add this line to your .pro file...

    LIBS +=-lbbdata

  • Get items from DataModel w/o ListView (QML)

    I have a DataModel object that is not connected to the ListView. It is used to store data only, analyzed of JSON.

    How to generate a variable row (QList) in QML to get the first object in the list?

    Has found the solution by myself:

           var indexPath = new Array();
           indexPath[0]=0;
           var item = infoDataModel.data(indexPath);
    
  • How can I change the layout of a listview of Interior programically qml

    Hello

    Is it possible to change the layout of a listview inside qml., i programically; e in both ways between the layout: StackListLayout for the layout: GridListLayout...

    I've never really tried, but given the way the QML syntax usually works I would try something like this:

    Page {
       attachedObjects: [
          DockListLayout {
             id: dock
          },
          GridListLayout {
             id: grid
          }
       ]
       ListView {
          id: list
          layout: dock
       }
       function toDock() {
          list.layout = dock;
       }
       function toGrid() {
          list.layout = grid;
       }
    }
    

    As I said I have not actually tried this, but this is where I would start to experiment.

Maybe you are looking for

  • key win 7 tx2 1160eo scrolling

    I had the version of conducting of windows earlier and could scroll with my finger in an iphone as a means. Now since I've upgraded to windows 7 Home Edition premium I can't do that. Anyone know if this is a setting that I can activate somehow?

  • Can I change the graphic card of Satellite C660 who is GF 315 m to 635M?

    My specification6 GB of ramCore i52.3 ghz

  • Distribution of the cDAQ

    Hi all I got the update from an old soft of NOR-DAQ to NIDAQmx trad (thanks guys!) but I have a question about the distribution. If I create a Setup program with only NOR-DAQmx run, it's already 300 MB but when I install it on a blank PC, hardware (c

  • CD DVD does not work

    I ran the troubleshooting, and I had a problem.  The disk in drive F is not detected or is not supported. I thought to uninstall and then reinstall the driver software.  Someone thinks it will solve my problem and if so where can I get the new driver

  • Windows XP asking to be activated before it will allow me to connect.

    original title: xp repair installation request to be activated before can connect you. After clicking Yes, the screen on the desktop (no icons) frezzes.