ListView / DataModel crash

Hello

I'll have a consistent crash in my application and could not find a solution. Basically I have a GroupDataModel as a QProperty in my main class. Then, I have a page with three buttons. Each button creates and opens a page different qml. One of the qml pages contains a ListView that is connected to the above mentioned data model. The first time the page is opened there is no problem. Then when I go back (which causes the page to be destroyed) and re-enter the page, it crashes. No other pages are affected and can be opened infinite times. I know that it is GroupDataModel, because if I change the listview datamodel to point to a temp .xml file I open this page again for unlimited times. Here are a few pieces of code that I feel are important to this question:

in class.hpp

public :Q_PROPERTY(bb::cascades::GroupDataModel *expensesModel READ expensesModel CONSTANT);

private :
bb::cascades::GroupDataModel* expensesModel() const;
bb::cascades::GroupDataModel* m_expensesModel;

in class.cpp

bb::cascades::GroupDataModel* ExpenseTracker::expensesModel() const {
    return m_expensesModel;
}

in the page containing the buttons:

Button {
                        text: "Loans"
                        onClicked: {
                            app.updateDataModel("", "Loan");
                            var page =loanPage.createObject();
                            page.type = "Loan"

                            mainNavigationPane.push(page);
                        }
                        attachedObjects: ComponentDefinition {
                            id: loanPage
                            source: "Expenses_QML/ExpensePage.qml"
                        }
                    }
                    Button {
                        text: "Reports"
                        onClicked: {
                            var page = reportPage.createObject();
                            mainNavigationPane.push(page);
                        }
                        attachedObjects: ComponentDefinition {
                            id: reportPage
                            source: "Reports_QML/ReportPage.qml"
                        }
                    }

reportPage can be opened permanently, only expensePage.

In the navigation pane:

    onPopTransitionEnded: {
        console.log("got here");
        page.destroy();
    }

In ExpensePage.qml (which cannot be opened once)

ListView {
            onTriggered: {
                var viewExpensePage = viewExpensePageDef.createObject();
                viewExpensePage.expenseData = dataModel.data(indexPath);
                mainNavigationPane.push(viewExpensePage)
            }
            layout: StackListLayout {
            }
            /* with only this changed page can be opened infinite times
             * dataModel: XmlDataModel {
             * source: "models/sheetmodel.xml"
             * } */
            dataModel: app.expensesModel
            listItemComponents: [
                ListItemComponent {
                    type: "item"
                    id: listItemComponent
                    ExpenseListItemView {
                        id: thumbListView
                    }
                }
            ]
        }

I absolutely need this page to be created and deleted everything being open/closed, because it is the key in my architecture. So I can't solve this problem the "cheating" way to not destroy the page and leaving always responsible. All suggestions are welcome! If more code is needed let me know and I'll add it.

Thank you

Gerry

You cannot use the same datamodel on several lists, you try to do?

In addition, when a page is destroyed, everything on the page gets destroyed, so when listview is destroyed, it removes also the datamodel, who so if you try and open the page again, you will be the datamodel of new listview to an address memory random with nothing there, it will crash.

Tags: BlackBerry Developers

Similar Questions

  • dynamically create and bind datamodel and listview

    Hello

    I looked through forums and examples, but in all the listview/datamodel example are linked since the start of the application only. I need to create and link dynamically. Because my data listview will depend on the selection of the previous shape. Need to do using qml. Can someone help me?

    I have not seen that your souce code can only guess the possibility.

    You have set the query, like "query:" / xxx/yyy "? You can add the journal to your custom data source to check the loop iteration of data?

    If you can show your brief source code, it willl be quick analysis.

  • very simple custom DataModel derived from bb::cascades:DataModel will not display data in ListView

    Hello

    A model of custom data in C++, I did nothing appears in a ListView

    It seems that the link

    listView.dataModel = _dataModel

    on QML side don't ask the DataModel data. I'm not really sure what I'm doing wrong.

    PS. Place the CustomDataModel in QML as an attachedObject and insert data it works, but I have a specific need to keep the DataModel in C++.

    Below the example of code reduced to the simplest case which cause me problem:

    //customdatamodel.h
    
    #include 
    #include 
    #include 
    
    class CustomDataModel : public bb::cascades::DataModel
    {
    Q_OBJECT
      public:
        CustomDataModel(QObject * parent=0) : bb::cascades::DataModel(parent)
        {
        }
        virtual void ~CustomDataModel()
        {
        } 
    
        virtual int CustomDataModel::childCount(const QVariantList& indexPath)
        {   //just one level deep
            return 0;
        }
    
        virtual bool CustomDataModel::hasChildren(const QVariantList& indexPath)
        {
            return childCount(indexPath) > 0;
        }
    
        virtual QVariant CustomDataModel::data(const QVariantList& indexPath)
        {
            if (indexPath.count() == 1)
            {
                return m_values[indexPath[0].toInt()];
            }
            return QVariant();
        }
    
        void CustomDataModel::insert(const QVariantMap &item)
        {
             m_values.append(item);
             emit itemAdded(QVariantList() << m_values.count()-1);
        }
    
        private:
          QVariantList m_values;
    }
    
    //application.cpp
    
    ApplicationUI::ApplicationUI(bb::cascades::Application *app)
    : QObject(app)
    {
        qmlRegisterType("app.datamodels", 1,0, "CustomDataModel");
        QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    
        CustomDataModel *dataModel = new CustomDataModel(this);
    
        QVariantMap map;
        map["field"] = "value1";
        dataModel->insert(map);
    
        map = QVariantMap();
            map["field"] = "value2";
        dataModel->insert(map);
    
        map = QVariantMap();
        map["field"] = "value3";
        dataModel->insert(map);
    
        qml->setContextProperty("_dataModel", dataModel);
    
        AbstractPane *root = qml->createRootObject();
        app->setScene(root);
    }
    
    //main.qml
    
        Page {
            Container {
                layout: DockLayout {
                }
    
                ListView {
                    id:listView
                    dataModel: _dataModel
    
                    function itemType(data, indexPath)
                    {
                        if (indexPath.length == 1)
                        {
                            return "item";
                        }
                    }
    
                    listItemComponents: [
    
                        ListItemComponent {
                            type: "item"
                            StandardListItem {
                                title: ListItemData.field
                            }
                        }
                    ]
                }
            }
        }
    

    Hello
    You always return a zero childCount, so he thinks that the template is empty.

  • findChild custom datamodel

    Hello

    I know how to recover a QML from C++ object. For example, if myObj is a component TextArea, I can change the text like this:

    QObject *obj = appPage->findChild("myObj");
    if (myObj){
        myObj->setProperty("text", "hello");
    }
    

    Now, I would get the DataModel for a ListView, which is a custon DataModel:

    ListView {
        dataModel: searchModel
    ...
    }
    
    attachedObjects: [
    
        SearchModel {
            id: searchModel
            jsonAssetPath: "app/native/assets/appsearch.json"
            filter: "All categories"
        }
    ]
    

    At least, my SearchModel has one public slot: void updateListWebviews (const QString text);

    I want to trigger the updateListWebviews slot in a function of the CPP. Could you help me to achieve this please?

    Thanks for your help,

    Laurent

    You can access 'qml objects' very well, behind the scenes, they are ordinary objects in c ++.

    You can call a qml method using QMetaObject::invokeMethod

    You can also connect a signal c ++ in qml and just send the signal to your user interface. I judge that the most elegant solution.

  • ListView and the height of a CustomListItem

    I have created a ListView with a CustomListItem. The code looks like the following:

    ListView {
        dataModel: myDataModel
        listItemComponents: [
            ListItemComponent {
                type: "item"
                CustomListItem {
                     Container {
                        layout: StackLayout {}
                        TextArea {
                            text: ListItemData.data
                            multiline: true
                        }
                        TextArea {
                            text: ListItemData.data2
                            multiline: true
                        }
                    }
                }
            }
        ]
    }
    

    I came across this problem recently. I suggest to create a personalized yourself list item and do not use the CustomListItem class, I think it is buggy in that regard.

  • ListView grid change to list dynamically

    Dear developers

    I have a listview that is represented by a grid. But I want a menuaction to change the schedule to the list and vice versa. But it seems more difficult, so I thought. My griditems are different then my listitems. For those who must change too.

    That's what I have so far but I'm stuck to be honest.

    import bb.cascades 1.0
    
    Container {
        property bool isGrid: true
    
        ListView {
            id: listView
            dataModel: channelListVM.otherDataModel
            horizontalAlignment: HorizontalAlignment.Fill
            layoutProperties: StackLayoutProperties {
                spaceQuota: 1.0
            }
            layout: isGrid ? gridLayout : stackLayout
            listItemComponents: [
                ListItemComponent {
                    type: "gridItem"
                    GridItem {
                        contextActions: ActionSet {
                            title: ListItemData.name
                            actions: [
                                ActionItem {
                                    title: qsTr("Favorite")
                                    imageSource: "asset:///img/bb_action_favorites.png"
                                    onTriggered: {
                                        ListItemData.favorite()
                                    }
                                }
                            ]
                        }
                    }
                },
                ListItemComponent {
                    type: "listItem"
                    MyListItem {
                        contextActions: ActionSet {
                            title: ListItemData.name
                            actions: [
                                ActionItem {
                                    title: qsTr("Favorite")
                                    imageSource: "asset:///img/bb_action_favorites.png"
                                    onTriggered: {
                                        ListItemData.favorite()
                                    }
                                }
                            ]
                        }
                    }
                }
            ]
    
            function itemType(data, indexPath) {
                if(isGrid) {
                    return "gridItem";
                }
    
                return "listItem";
            }
    
            attachedObjects: [
                StackListLayout {
                    id: stackLayout
                },
                GridListLayout {
                    id: gridLayout
                    columnCount: 3
                    horizontalCellSpacing: 10.0
                    verticalCellSpacing: 10.0
                    cellAspectRatio: 1
                }
            ]
        }
    }
    

    And when I change the isGrid true or false, it amends the provision but it seems that the UI is not updated. How can I fix without working with 2 ListViews and hide/show them about the property?

    Thanks in advance

    Since you're using the itemType function you do not require a change in your database. However, given that you match the layout of your choice of item type, you will need to notify the ListView that its cache is no longer valid. If ListView will not selection of the type of return until you load a new element in its cache.

    To do this, you just have your DataModel emit a signal after you change your property to isGrid. This is done via DataModel::itemsChanged. Since you want your entire list to rebuild, you want to give him the DataModelChangeType::Init.

    Code wise, you need to add this call:

    channelListVM.otherDataModel.itemsChanged(DataModelChangeType.Init)
    
  • How to get the content of the list item selected ListView using CPP?

    Hello

    I do a simple application, get the content of the list item selected ListView using CPP, in the main.qml file, I created a listview using XMLDataModel and I got the selected listview using dataModel.data (row) .attributeNameInXmlfile in qml. content as in the same way the ListView using cpp.please help me I want to get the content of the listitem selected.

    Here is my code

    hand. QML

    import bb.cascades 1.0
    
    Page {
        content: Container {
            id: mainContainer
            objectName: "container"
            // property alias selectedText: selectedTextField.text
            //property alias deselectedText: deselectedTextField.text
            ListView {
                objectName: "listView"
                dataModel: XmlDataModel {
                    source: "models/items.xml"
                    id: model
                }
                listItemComponents: [
                    ListItemComponent {
                        type: "item"
                        StandardListItem {
                            title: ListItemData.title
                        }
                    }
                ]
            }
            TextField {
                id: selectedTextField
                objectName: "selectedTextField"
                text: ""
            }
            TextField {
                id: deselectedTextField
                objectName: "deselectedTextField"
                text: ""
            }
        }
    }
    

    App.cpp

    #include "app.hpp"
    
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    using namespace std;
    
    using namespace bb::cascades;
    QObject *textFieldSelected ;
    QObject *textFieldNotSelected;
    QObject *list;
    App::App() {
        QmlDocument *qml = QmlDocument::create("main.qml");
        AbstractPane *root = qml->createRootNode();
        list = root->findChild("listView");
        textFieldNotSelected = root->findChild("deselectedTextField");
        textFieldSelected = root->findChild("selectedTextField");
        QObject::connect(list,SIGNAL(selectionChanged (QVariantList, bool)),this,SLOT(changeText(QVariantList, bool)));
        Application::setScene(root);
    }
    
    void App::changeText(QVariantList indexPath,bool selected) {
    
    }
    

    App.HPP

    #ifndef APP_H
    #define APP_H
    
    #include 
    #include 
    #include 
    
    /*!
     * @brief Application GUI object
     */
    class App : public QObject
    {
        Q_OBJECT
    public:
        App();
    public slots:
    void changeText(QVariantList ,bool );
    
    };
    
    #endif // ifndef APP_H
    

    Try this.

    void App::changeText(QVariantList indexPath,bool selected) {
        XmlDataModel *model = (XmlDataModel *)list->dataModel();
        QVariantMap map = model->data(indexPath).toMap();
        // map is your data in QVariant
        qDebug() << map["title"].toString();
    }
    
  • ListView and ListItem displaying funny

    How is it when I have my. XML directly in my ListView, all list items display correctly, but if I add data to a data source, it is not.

    Example below because I can't explain it very well.

    ListView {
                dataModel: XmlDataModel {
                    source: "hills.xml"
                }
                listItemComponents: [
                    ListItemComponent {
                        type: "listItem"
                        StandardListItem {
                            title: ListItemData.skiHill
                        }
                    },
                    ListItemComponent {
                        type: "header"
                        Header {
                            title: ListItemData.key
                            touchPropagationMode: TouchPropagationMode.None
                        }
                    }
    

    Vs.

    ListView {
                dataModel: dataModel
                listItemComponents: [
                    ListItemComponent {
                        type: "listItem"
                        StandardListItem {
                            title: ListItemData.skiHill
                        }
                    },
                    ListItemComponent {
                        type: "header"
                        Header {
                            title: ListItemData.key
                            touchPropagationMode: TouchPropagationMode.None
                        }
                    }
    
    ...
    
    attachedObjects: [
            GroupDataModel {
                id: dataModel
                sortingKeys: [
                    "skiHill"
                ]
            },
            DataSource {
                id: dataSource
                source: "hills.xml"
                query: "/root/listItem"
                onDataLoaded: {
                    dataModel.insertList(data);
                }
            }
    

    On the 2nd day of two different types of lists, the list item displays the news from another part of my XML, not the name of ski hill.

    Your head should look like:

     ListItemComponent {
                        type: "header"
                        Header {
                            title: ListItemData
                            touchPropagationMode: TouchPropagationMode.None
                        }
                    }
    

    i.e. just use ListItemData for the title - because since a GroupDataModel (and probably XmlDataModel) the first level of the row is always returned as a string, not as a piece of real data that has properties

    ListItemComponent {
                        type: "item"
                        StandardListItem {
                            title: ListItemData.skiHill
                        }
                    },
    

    Your list items must have the type 'point' - because that's what indicates the GroupDataModel.

    You can substitute by using a reminder in QML itemType(), if you need something different, or if you need a mixture of different types in the list

  • Child parsing JSON with datasource and view in listview

    Hi, I use datasource to get json from url data and I want in the listview, but json data have child, so I don't know how to access.

    My data source code here:

    DataSource {
            id: serviceDataSource
            source: "http://services.okezone.com/json/headline"
            type: DataSourceType.Json
            onDataLoaded: {
                serviceDataModel.clear();
                serviceDataModel.insertList(data)
            }
        }
    

    And here my display list code:

    ListView {
              dataModel: serviceDataModel
              listItemComponents: [
    
                   ListItemComponent {
                          type: "news"
                          ServiceDetail {
                                 title: ListItemData.title
                                 pubDate: ListItemData.published
                          }
                   }
              ]
     }
    

    And here is the response from json to this url:

    [
    
    {
    
      "okezone": {
    
         "version": "0.1",
    
         "headline": {
    
            "request": {
    
               "channel": 0,
    
               "start": 0
    
            },
    
            "status": "OK",
    
            "more": {
    
               "offset": 2,
    
               "start": 0,
    
               "total": 2
    
            },
    
            "news": {
    
               "type": "2",
    
               "id": "796135",
    
               "channel": {
    
                  "id": "519",
    
                  "label": "Surabaya"
    
               },
    
               "published": "2013-04-23 13:21:25",
    
               "title": "Gara-Gara UN, Mendikbud Didesak Mundur",
    
               "summary": "Para orangtua murid menilai, Mendikbud, Muhammad Nuh, harus bertanggung jawab di balik kesemerawutan sistem dan pelaksanaan Ujian Nasional.",
    
               "thumbnail": "http://img.okeinfo.net/images-data/content/2013/04/23/519/796135/BkuPxui4gB.jpg",
    
               "url": "http://services.okezone.com/json/detail/2013/04/23/519/796135"
    
            }
    
         }
    
      }
    
    }
    ]
    

    Thanks for your help, I do it in two days and does not work.

    Hello

    Try this code

    import bb.cascades 1.0
    import bb.data 1.0
    
    Page {
        content: Container {
            Label {
                text: "List View with json parsing"
            }
    
            ListView {
                id: listViewDemo
                dataModel: GroupDataModel {
                    grouping: ItemGrouping.None
                }
    
                listItemComponents: [
                    ListItemComponent {
                        type: "listItem"
                        StandardListItem {
                            title: ListItemData.okezone.headline.news["title"]
                        }
                    }
                ]
    
                function itemType(data, indexPath) {
                    return "listItem";
                }
            }
        }
    
        attachedObjects: [
            DataSource {
                id: serviceDataSource
                source: "http://services.okezone.com/json/headline"
                type: DataSourceType.Json
                onDataLoaded: {
                    listViewDemo.dataModel.clear();
                    listViewDemo.dataModel.insertList(data)
                }
            }
        ]
    
        onCreationCompleted: {
            serviceDataSource.load();
        }
    }
    

    Don't forget to add the library to .pro file

    LIBS +=-lbbdata

  • Looking for example SQL to group ListView

    I'm looking for some examples showing how to connect the SQL bb::data :ataAccessReply to a ListView dataModel so that I can have headers for the returned items where the headers are part of the returned SQL data.

    For example

    Data in the table :

    Row1 [col1:A, col2:1,...]

    row2 [col1:A, col2: 2,...]

    row3 [col1:B, col2: 1,...]

    row4 [col1:B, col2: 2,...]

    ListView expected created from the dataModel:

    headerItem: has

    listItem1: title = 1, description =..., status =...

    listItem2: 2, description =..., status =...

    headerItem: B

    listItem3: 1, description =..., status =...

    listItem3: 2, description =..., status =...

    It seems to me something as a "group by" device to create the elements of headers.  But it is is not clear to me that I have to do to get there.

    Take a look at GroupDataModel. I think it will meet your needs.

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

  • 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()

  • Can't get multiple selections of work ListView

    The example code here seems very simple:

    https://developer.BlackBerry.com/native/reference/Cascades/bb__cascades__multiselecthandler.html

    I use the code example to use with ListView as my model:

                ListView {
                    id: listView
                    objectName: "listView"
                    dataModel: photosModel.photoGridModel
    
                    snapMode: SnapMode.LeadingEdge
    
                    layout: GridListLayout {
                        id: gridListLayout
                        objectName: "gridListLayout"
                    }
    
                    onTriggered: {
                        var newPage = photosPageDefinition.createObject();
                        photosModel.setPage(newPage);
                        navigationPane.push(newPage);
                        navigationPane.peekEnabled = false;
                        photosModel.launchFullscreen(indexPath);
                    }
    
                    multiSelectAction: MultiSelectActionItem {}
    
                    multiSelectHandler {
                        // These actions will be shown during multiple selection, while this
                        // multiSelectHandler is active
                        actions: [
                            ActionItem
                            {
                                title: "Tag"
                                imageSource: "asset:///images/tag.png"
                                onTriggered: {
                                    // TODO
                                }
                            },
                            ActionItem
                            {
                                title: "Share"
                                imageSource: "asset:///images/share.png"
                                onTriggered: {
                                    // TODO
                                }
                            },
                            ActionItem
                            {
                                title: "Move"
                                imageSource: "asset:///images/folder.png"
                                onTriggered: {
                                    // TODO
                                }
                            },
                            DeleteActionItem
                            {
                            }
                        ]
    
                        status: "None selected"
    
                        onActiveChanged: {
                            if (active == true) {
                                console.log("Multiple selection is activated");
                            }
                            else {
                                console.log("Multiple selection is deactivated");
                            }
                        }
    
                        onCanceled: {
                            console.log("Multi selection canceled!");
                        }
                    }
                }
    

    When loading the application, I long press on an item in the GridView control and nothing happens.

    Can you clarify what this means 'does not '?.

    EDIT:

    OK, now I see. To make it work, you must set an empty or nonempty ActionSet for each listitem.

    StandardListItem {
        title: ListItemData.title
        contextActions: [
            ActionSet {
            }
        ]
    }
    

    Now, it will work.

  • ListView with GridListLayout will not display items

    I can easily create a ListView that displays its items.

    The following XML code:

    
        

    And here's the QML:

                ListView {
                    dataModel: XmlDataModel {
                        source: "asset:///test.xml"
                    }
    
                    listItemComponents: [
                        ListItemComponent {
                            type: "header"
                            Header {
                                title: ListItemData.title
                            }
                        },
                        ListItemComponent {
                            type: "item"
                            Label {
                                text: ListItemData.name
                            }
                        }
                    ]
                }
    

    The result looks like this:

    But what I really want are the items to display in a grid. To do this, I put the ListView layout property to a GridListLayout:

                    layout: GridListLayout {
                    }
    

    When I do that, it shows more elements, only the headers:

    What I am doing wrong?

    In the end I tried to get this working using a custom LitemItemProvider that uses images for the elements, but even once, it would display only the headers.  So I simplified my example as much as I can above to try to identify the problem.  I don't know how to do the simple example.  I am able to get my original code works fine even with the GridListLayout if I do not activate the grouping - as soon as I activate the grouping (so that the data has headers and elements), it starts to behave like that.

    The display of the grid is not compatible with the Group?  The application of native images only grouping with a grid view, and I am trying to imitate that.  Super confused.

    You must set headerMode

    https://developer.BlackBerry.com/native/reference/Cascades/bb__cascades__gridlistlayout.html#propert...

  • How can I place a listview in a listview?

    Hello everyone.

    I do an application on my website and I would like to have an area featured inside, but I found a big problem when I try to add the recommended area to the main Listview (where the post is loaded).

    It is an example of what he would like to see inside my application:

    So I want to spend the "Star box" and "Feeding zone" at the same time, when the user tries to scroll vertically.

    I tried to use a ScrollView but the priority of scrolling is in vertical listview and the recommended area does not scroll only when the vertical scroll listview is finished.

    Could someone give me a suggestion?

    See you soon!

    I don't think we have an example that does exactly what you want, but basically, you could create a CustomListItem contains inner ListView.  You would need a second source of data for inner ListView or have the first element of your main data source to be another source of data.

    The main ListView could choose the ListItem to display based on a type item in the data source main or you could rely on the position. forumThreadList.qml shows how you can override the itemType method to select the type of item (if it is not defined in the original data source).  This example also shows how to use a CustomListItem, but not one that contains a ListView.

    Here is another example that shows a part of the implementation.  It would have a horizontal ListView in all the ranks of the main list.  If you combine these two you should be able to get what you are looking for.  Let me know if you have any questions along the way.

    import bb.cascades 1.2
    
    // creates one page with a label
    Page {
        attachedObjects: [
            //ComponentDefinition doesn't work because DataModel doesn't extend BaseObject
            ArrayDataModel {
                id: dm2
            },
            ArrayDataModel {
                id: dm3
            }
        ]
        Container {
            ListView {
                dataModel: ArrayDataModel {
                    id: dm
                }
                listItemComponents: [
                    ListItemComponent {
                        Container {
                            layout: StackLayout {
                                orientation: LayoutOrientation.TopToBottom
                            }
                            ListView {
                                preferredHeight: 100
                                //Thankfully the QVariant is a DataModel, so this works :)
                                dataModel: ListItemData
                                layout: StackListLayout {
                                    orientation: LayoutOrientation.LeftToRight
                                }
                                listItemComponents: [
                                    ListItemComponent {
                                        Container {
                                            layout: StackLayout {
                                                orientation: LayoutOrientation.LeftToRight
                                            }
                                            Label{
                                                text: ListItemData +"\t|\t"
                                            }
                                        }
                                    }
                                ]
                            }
                            Divider {}
                        }
                    }
                ]
            }
        }
        onCreationCompleted: {
            dm2.append(["This is","another list","inside of","the first one"])
            dm3.append(["<( \" <) <( \" <) <( \" <)","(^\"^) (^\"^) (^\"^)","(> \" )> (> \" )> (> \" )>","(^\"^) (^\"^) (^\"^)","(> \" )><( \" )><( \" <)","(^\"^) (^\"^) (^\"^)","<( \" <) (>\"<) (> \" )>","(v' 'v) (v' 'v) (v' 'v)"])
    
            dm.append(dm2)
            dm.append(dm3)
        }
    }
    
  • Update of ListView dummy image using images from URL http

    Hi guys...

    Please help me with this.

    I have created a ListView in QML file and filled with data received from a webservice. Since this web service provides all the images, I have to place a dummy image at this location. Then I used another method to retrieve images of the url. Now, I got the image in my CPC file. But I could not update my listview. I tried several methods. But failed.

    Here is my code snippet.

     ListView {
                    id: listView
                    objectName: "listView"
    
                    dataModel: ArrayDataModel {
                        id: myListModel
    
                    }
    
                    // Override default GroupDataModel::itemType() behaviour, which is to return item type "header"
                    listItemComponents: ListItemComponent {
                        id: listcomponent
                        // StandardListItem is a convivience component for lists with default cascades look and feel
                        StandardListItem {
                            title: ListItemData.postText
                            description: ListItemData.postDate
                            status: ListItemData.filePath
                            imageSource: "asset:///images/4.png"
                        }
    
                    }
                    layoutProperties: StackLayoutProperties {
                        spaceQuota: 1.0
                    }
                    horizontalAlignment: HorizontalAlignment.Fill
                    verticalAlignment: VerticalAlignment.Fill
    
                }
    

    In the PRC, I get my image like this.

    void PostHttp::imageFetcher(){
    const QUrl url("http:///828/828_20135312012288.png");
    if (flag1 == true) {
        get(url);
    }
    }
    void PostHttp::onImageReply(){
        QNetworkReply* reply = qobject_cast(sender());
        QString response;
        QImage img;
        QString filePathWithName = "data/img/";
        QString imageName;
    
        if (reply) {
                if (reply->error() == QNetworkReply::NoError) {
                    flag1 = false;
                    const int available = reply->bytesAvailable();
                    if (available > 0) {
                    const QByteArray buffer(reply->readAll());
                    response = QString::fromUtf8(buffer);
                    img.loadFromData(buffer);
                    img = img.scaled(40, 40, Qt::KeepAspectRatioByExpanding);
                    const QImage swappedImage = img.rgbSwapped();
                    const bb::ImageData imageData = bb::ImageData::fromPixels(
                            swappedImage.bits(), bb::PixelFormat::RGBX,
                            swappedImage.width(), swappedImage.height(),
                            swappedImage.bytesPerLine());
                    bb::utility::ImageConverter::encode(QUrl(QDir::currentPath() + "/shared/camera/img.png"), imageData, 75);
                    qDebug()<<"current path is "<
    

    Thanks in advance

    You can pass a QByteArray of image data coded directly to an imageView in the image property, set of QVariant::fromValue (). However, in your case you can place the uri to which you saved the image and not the bytes. Advantage: cascades puts these images in cache. If you use deterministic file names, you can avoid any networking calls or loading of images when only the populated list of point sier after be recycled.

    img.loadFromData(buffer);
    img = img.scaled(40, 40, Qt::KeepAspectRatioByExpanding);
    img.save(QDir::currentPath() + "/shared/camera/img.png"), 0, 75);
    

    QImage can do all this for you, without permutation of bytes.

    All you have to do is then updated the datamodel.

Maybe you are looking for

  • songs are downloaded by itself in music Apple

    I have a problem with music from Apple on iphone. All the song time downloading by itself when I'm adding new song (or album) radio to my playlist. How can I disable this function? Or what I'm supposed to do? P.S. Sorry for the typos, English is not

  • run dll error loading C:/users/mike/AppData/Local/uwamocin.dll module could not be found...

    I am running windows vista Home premium. When my screen, I get an error loading c:\Users[user-name]\Music\iTunes\iTunes/mike/AppData/Local/uwamocin.dll module could not be found. My internet explore continues to mess up and running slow, I had other

  • CUCMBE migration to LDAP Synch

    HI - we currently have a 7.1.5.1000 facility - 12 autonomous CUCMBE which is in place for a few months.  The end-user CUCM database is local and the user CUC were imported from this local database.  Our customer now wants end users to WHAT LDAP integ

  • Manually change the IP address on 8500 A909g

    After the 8500 A909g printer has been turned off for a few days, the program on my computer HP solutions Center portable 32-bit Vista now displays a message 'disconnected '. The IP address is now 169.254.184.17 By HP, troubleshooting instructions and

  • WAN Miniport problem?

    Hello everyone do not know what is happening, but what is the problem. Miniport Wan (Network Monitor) has a driver problem. WAN Miniport (IP (has a driver problem.) Miniport WAN (IPv6) has a driver problem. It says to reinstall the device drivers. Ho