ListItemData in onCreationCompleted

Hello

It seems as if the value of ListItemData in onCreationCompleted is not properly set to each element. I get the same element repeatedly as onCreationCompleted comes again and again for different created items.

This can easily be demonstrated in the sample application CascadesCookbook. Just add these lines at the end of RecipeItem.qml and you will see what I mean:

onCreationCompleted: {}
Console.log ("RecipeItem onCreationCompleted" + ListItemData.title);
}

If anyone has comments on it, I would be very grateful. I will be happy to enter in this as a bug in the Manager of incidents, but wanted to check first on the forum, to the case where someone spots I do something wrong.

Thank you

Jamie

I discovered that I can use ListItem.onInitializedChanged to be notified when the Visual element has been created and initialized to propely. In this context, the ListItemData has the correct value.

Tags: BlackBerry Developers

Similar Questions

  • Changing the beta version code from Beta2

    Hello again,

    I worked on a twitter feed getting charged through the solution found hereJSON data analysis, however the Beta 2 of the NDK shows a new error I have ever had with the original beta version...

    The following code gives me an error 'Uknown property' for statusTest and descriptionText near the bottom

    Page {
        content: Container {
            background : Color.DarkRed
            layout : DockLayout {
            }
            ListView {
                layoutProperties : DockLayoutProperties {
                    verticalAlignment : VerticalAlignment.Center
                }
                objectName : "basicTimelineView"
                id : basicTimelineView
                listItemComponents: [
                    ListItemComponent {
                        type: "item"
                        StandardListItem {
                            statusText: {
                                ListItemData.created_at
                                }
                            descriptionText: {
                                ListItemData.text
                                }
                        }
                    }
                ]
            }
        }
        onCreationCompleted: {
            cs.getTimeline("ladygaga");
        }
    }
    

    Is it a documented change? Or maybe someone can quickly explain what I need to change.

    Thank you very much!!

    Changes:
    statusText-> status
    descriptionText-> description
    titleText-> title

    And you don't need {and} near ListItemData.created_at and ListItemData.text.

  • Dynamic content of ListItem

    Hello!

    I have a listview with messages. Each message is the text (body) and attachments (Images, videos, links etc.). To display the body I use 'ListItemData.body '. But what is the best way to view attachments (it is an array of types and links?) I tried to pass the qml container pointer to c ++ (and add controls to the container in c ++) but failed to make it work... Another question that this part should be clickable so that it could be opened.

    The best option, I'd like to see is to browse in QML table accessories add qml objects like ImageView to the container of attachments, but do not know how to implement this...

    All advice is appreciated!

    Thanks for your help!

    Found the answer here:

    https://supportforums.BlackBerry.com/T5/native-development/ListItemData-in-onCreationCompleted/TD-p/...

    I use ListItem.onInitializedChanged for updating content ListItem!

  • Method to apply a style HTTP in Cascades/QML?

    Something like AJAX. What is the equivalent in Cascades/QML? What classes should I Explorer in the API?

    Advice would be greatly appreciated.

    Applications vary.

    http://someservice.com/v1/do/blah

    http://someservice.com/v1/do/meh

    The output of the service is JSON.

    I'll take the exit and probably put it in a list (much like the sample application of stamp collector)

    Help me get started at all help or sample code would be really useful. I imagine that it would be useful for developers who integrate their stunts BB10 app API or data of third parties.

    Thank you!

    Hello

    I wrote a simple example application to show how to create an application that consumes a twitter feed and display JSON content crawled in a standard list view.

    First create a new project named 'Twitter', by selecting file-> New-> BlackBerry Cascades C++ Project, and then choose the option "Empty project" Standard.

    We will start by creating a class called TwitterRequest responsible for the download and let us know through the slots and signals that the twitter JSON data is available. This class must be placed in your src/folder of the project

    TwitterRequest.hpp

    /*
     * Copyright (c) 2011-2012 Research In Motion Limited.
     *
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */
    
    #ifndef TWITTERREQUEST_HPP_
    #define TWITTERREQUEST_HPP_
    
    #include 
    
    /*
     * This class is responsible for making a REST call to the twitter api
     * to retrieve the latest feed for a twitter screen name. It emits the complete()
     * signal when the request has completed.
     */
    class TwitterRequest : public QObject
    {
        Q_OBJECT
    public:
        TwitterRequest();
        virtual ~TwitterRequest();
    
        /*
         * Makes a network call to retrieve the twitter feed for the specified screenname
         * @param screenname - the screen name of the feed to extract
         * @see onTimelineReply
         */
        void getTimeline(QString screenname);
    
    public slots:
        /*
         * Callback handler for QNetworkReply finished() signal
         */
        void onTimelineReply();
    
    signals:
        /*
         * This signal is emitted when the twitter request is received
         * @param info - on success, this is the json reply from the request
         *               on failure, it is an error string
         * @param success - true if twitter request succeed, false if not
         */
        void complete(QString info, bool success);
    };
    
    #endif /* TWITTERREQUEST_HPP_ */
    

    TwitterRequest.cpp

    /*
     * Copyright (c) 2011-2012 Research In Motion Limited.
     *
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */
    
    #include "TwitterRequest.hpp"
    #include 
    #include 
    #include 
    #include 
    #include 
    
    TwitterRequest::TwitterRequest()
    {
    }
    
    TwitterRequest::~TwitterRequest()
    {
    }
    
    void TwitterRequest::getTimeline(QString screenname)
    {
        QNetworkAccessManager* netManager = new QNetworkAccessManager();
        if (!netManager)
        {
            qDebug() << "Unable to create QNetworkAccessManager!";
            emit complete("Unable to create QNetworkAccessManager!", false);
            return;
        }
    
        QString queryUri = "http://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_n...";
        queryUri += screenname;
        QUrl url(queryUri);
        QNetworkRequest req(url);
    
        QNetworkReply* ipReply = netManager->get(req);
        connect(ipReply, SIGNAL(finished()), this, SLOT(onTimelineReply()));
    }
    
    void TwitterRequest::onTimelineReply()
    {
        QNetworkReply* reply = qobject_cast(sender());
        QString response;
        bool success = false;
        if (reply)
        {
            if (reply->error() == QNetworkReply::NoError)
            {
                int available = reply->bytesAvailable();
                if (available > 0)
                {
                    int bufSize = sizeof(char) * available + sizeof(char);
                    QByteArray buffer(bufSize, 0);
                    int read = reply->read(buffer.data(), available);
                    response = QString(buffer);
                    success = true;
                }
            }
            else
            {
                response =  QString("Error: ") + reply->errorString() + QString(" status:") + reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toString();
                qDebug() << response;
            }
            reply->deleteLater();
        }
        if (response.trimmed().isEmpty())
        {
            response = "Twitter request failed. Check internet connection";
            qDebug() << response;
        }
        emit complete(response, success);
    }
    

    Then, replace the main.qml with the following content.

    import bb.cascades 1.0
    
    Page {
        content: Container {
            background : Color.DarkRed
            layout : DockLayout {
            }
            ListView {
                layoutProperties : DockLayoutProperties {
                    verticalAlignment : VerticalAlignment.Center
                }
                objectName : "basicTimelineView"
                id : basicTimelineView
                listItemComponents: [
                    ListItemComponent {
                        type: "item"
                        StandardListItem {
                            statusText: {
                                ListItemData.created_at
                            }
                            descriptionText: {
                                ListItemData.text
                                }
                        }
                    }
                ]
            }
        }
        onCreationCompleted: {
            cs.getTimeline("ladygaga");
        }
    }
    

    This is a simple page with a ListView with standard components, indicating the date and the content of the tweet. As you can see, immediately after that page is created a call is made in the c++ code by using the context property 'cs' set in the constructor for the App to retrieve the latest tweets of the usernamed "ladygaga". To learn more about the call c ++ QML here https://bdsc.webapps.blackberry.com/cascades/documentation/ui/integrating_cpp_qml/index.html

    Finally, this linking is the App class. It uses slot machines to handle the "full" signal generated by the class TwitterRequest when data are available, analyzes the data in a model of GroupData and fills the ListView with the recovered data.

    App.HPP

    #ifndef APP_H
    #define APP_H
    
    #include 
    #include 
    
    class App : public QObject
    {
        Q_OBJECT
    
    public:
        App();
    
        /*
         * Called by the QML to get a twitter feed for the screen nane
         */
        Q_INVOKABLE void getTimeline(QString screenName);
    
    public slots:
        /*
         * Handles the complete signal from TwitterRequest when
         * the request is complete
         * @see TwitterRequest::complete()
         */
        void onTwitterTimeline(QString info, bool success);
    
    protected:
        bb::cascades::AbstractPane* m_root;
    };
    
    #endif // ifndef APP_H
    

    App.cpp

    #include 
    #include 
    #include 
    #include 
    #include 
    
    #include "App.hpp"
    #include "TwitterRequest.hpp"
    
    using namespace bb::cascades;
    
    App::App()
    {
        QmlDocument *qml = QmlDocument::create("main.qml");
        qml->setContextProperty("cs", this);
    
        m_root = qml->createRootNode();
        Application::setScene(m_root);
    }
    
    void App::getTimeline(QString screenName)
    {
        //sanitize screenname
        QStringList list = screenName.split(QRegExp("\\s+"), QString::SkipEmptyParts);
        if (list.count() <= 0)
        {
            qDebug() << "please enter a valid screen name";
            return;
        }
        QString twitterid = list[0];
    
        TwitterRequest* tr = new TwitterRequest();
        tr->getTimeline(twitterid);
        connect(tr, SIGNAL(complete(QString, bool)), this, SLOT(onTwitterTimeline(QString, bool)));
    }
    
    void App::onTwitterTimeline(QString info, bool success)
    {
        if (!success)
        {
            qDebug() << "Error retrieving twitter fee: " << info;
            return;
        }
    
        ListView* list = m_root->findChild("basicTimelineView");
        if (!list || list->dataModel() != NULL)
        {
            qDebug() << "basic list already populated";
            return; //if basic timeline list not found or already populated do nothing
        }
    
        // Create a group data model with id as the sorting key
        GroupDataModel* dm = new GroupDataModel(QStringList() << "id_str");
        dm->setGrouping(ItemGrouping::None);
    
        // parse the json response with JsonDataAccess
        bb::data::JsonDataAccess ja;
        QVariant jsonva = ja.loadFromBuffer(info);
    
        // the qvariant is an array of tweets which is extracted as a list
        QVariantList feed = jsonva.toList();
    
        // for each object in the array, push the variantmap in its raw form
        // into the ListView
        for (QList::iterator it = feed.begin(); it != feed.end(); it++)
        {
            QVariantMap tweet = it->toMap();
            dm->insert(tweet);
        }
    
        // set the data model to display
        list->setDataModel(dm);
        list->setVisible(true);
    }
    

    I hope that's enough to help you get started. There are many improvements that can be made, for example using multiple pages, load the ajax style tweets, even having a page where the twitter user name can be changed, and so on of error handling. Good luck!

    See you soon

    Swann

  • Why can't I access object inside the ListItemComponent.onCreationCompleted C++... ?

    Hello world

    My application has a HTTP connection to retrieve the XML stream and insert data to the ListView using DataSource and DataModel, and I want to hear at each of its ListView ListItem is created and completely to use a ListItemData for my c++ object. So I write my code like this

    In main.cpp

    int main (int argc, char * argv)

    {

    App app (argc, argv);

    new MyApp (&app);)

    returnApplication::exec();

    }

    In MyApp.cpp

    MyApp::MyApp (bb::cascades:Application * app): //constructor

    {QObject (app)}

    QmlDocument * qml = QmlDocument::create("asset:///main.qml").parent(this);

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

    AbstractPane * stream = qml-> createRootObject)

    App-> setScene (NCA);

    }

    void MyApp::doMyFunction (const QString & someData) {}

    qDebug()< "yes!!="">

    }

    In main.qml
    {Page}

    {Of container

    {To ListView

    dataModel: myDataModel

    listItemComponents:]

    {ListItemComponent}

    type: 'point '.

    {Of container

    onCreationCompleted: {}

    Console.log ("-LISTITEM ONCREATION COMPLETED");

    app.doMyFunction (ListItemData.someData);    //<  but="" console="" print="" about="" "can't="" find="" variable="" "app"="">

    }

    }

    }

    ]

    } //end listview

    } //end container

    onCreationCompleted: {}

    myDataSource.load ();

    }

    attachedObjects:]

    {GroupDataModel}

    ID: myDataModel

    },

    DataSource {}

    ID: myDataSource

    Source: "some URLs to get RSS... blah blah."

    type: DataSource.Xml

    onDataLoaded: {}

    myDataModel.clear ();

    myDataModel.insertList (data);

    }

    ]

    }

    I try to run mycode. But a console is printed on "can't find variable: app". " How can I solve this problem?

    Thanks for any suggestions.
    MAZ

    Its because the listitem is not in the same document as the Page tree really, he lives with ListView and does not have direct access to the elements of the Page.

    What you can do is create a javascript function in the ListView, and then the listitemcomponent facing, which in turn can relay to your environment variable "app."

    int listitemcomponent add id: itemContainer your container can
    itemContainer.ListItem.view.someFunctionDefinedInTheListView (data)

    in the listview:

    function somefunctiondefinedinlistview (data) {}
    app.doMyFunction (data)
    }

  • A return to the QML container onCreationComplete event Q_String

    Hello

    I'm trying to regain a QString funcition onCreationComplete a container.

    Here is the code I use.  When I debug the QML debugger jumps on the

    event and moves on to the next control.  I'm guessing that there is an error of some sort, but I don't know what it is.

    Thanks in advance.

    file .qml

    onCreationCompleted: {}
    If (ListItemData.channelName is {MSNApp.getSelectedChannel ()})
    Background = Color.create("#74D2F7")
    }
    }

    all files

    public:

    QString Q_INVOKABLE getSelectedChannel();

    private:

    QString selectedChannel;

    .cpp file

    selectedChannel = 'Home';  Download initialized in the constructor

    QString ApplicationUI::getSelectedChannel() {}

    Return selectedChannel;
    }

    Aparently there is a bug when it comes to properties of context and ListView.  I found this work around.

    Thanks for the suggestions.

    http://supportforums.BlackBerry.com/T5/Cascades-development/cannot-access-context-property-from-INSI...

    Best regards

    John

  • onCreationCompleted shipped before import JavaScript is over

    Hello

    I have a very small QML that matters a little JavaScript (128 lines) file that matters in turn another small JavaScript file (80 lines). In summary QML--> JS A--> JS B. In the JS files are essentially class definitions, and some small global code running. JS files have zero dependencies of the QML.

    The problem is that when the rootComponent.onCreationCompleted signal is distributed on the QML, JavaScript dependencies are not ready yet.

    I get a lot of erros as:

    asset:///Test.qml:10: TypeError: Result of expression 'ONA.inst' [undefined] is not an object.
    

    I also use the reminder of the Qt.include, Qt.include ("b.js", function() {}), a.js wait b.js be fully charged to a.js.

    I expect the onCreationCompleted signal of the element root to be shipped after all imports of JavaScript and its dependencies, where it is fully charged.

    I use BlackBerry10Simulator-BB10_2_1-3502 with VM Ware Fusion 7, under Mac OS X 10.10.3. Unfortunately I have not access to any real device.

    Please advice.

    You can try RenderFence, add this code to your object of root (TabbedPane, Page or NavigationPane) instead of onCreationCompleted:

       attachedObjects: [
            RenderFence {
                raised: true
                onReached: {
                    \\ your code goes here
                }
            }
        ]
    
  • Display QList ListItemData &lt; QVariantMap &gt; with &lt; QVariantMap &gt; QListDataModel

    Hey,.

    I have a declared list like so:

    ListView {
                    id: PostsList
                    preferredWidth: 700
                    objectName: "PostsList"
                    layoutProperties: DockLayoutProperties {
                        horizontalAlignment: HorizontalAlignment.Center
                    }
    
                    // A single component because there's no list header.
                    listItemComponents: [
                        ListItemComponent {
                            type: "post"
                            PostItem {
                            }
                        }
                    ]
                                    //Tried this hoping items were being misparsed as headers.
                    function itemType(data, indexPath) {
                            return 'item';
                    }
                }
    

    Where is PostItem.qml

    Container {
        id: itemRoot
        layout: DockLayout {
            leftPadding: 30
            rightPadding: leftPadding
            topPadding: 30
        }
    
        Container {
            preferredHeight: 250
            layout: DockLayout {
            }
            Label {
                //text: ListItemData.data.title
                text: ListItemData.title
                layoutProperties: DockLayoutProperties {
                    verticalAlignment: VerticalAlignment.Center
                    horizontalAlignment: HorizontalAlignment.Center
                 }
            }        Label {            //text: ListItemData.data.title            text: ListItemData.description            layoutProperties: DockLayoutProperties {                verticalAlignment: VerticalAlignment.Center                horizontalAlignment: HorizontalAlignment.Center             }        } }
    
        // Signal handler for list item activation.
        ListItem.onActiveChanged: {
            setHighlight (ListItem.active);
        }
    
        // Signal handler for list item selection.
        ListItem.onSelectedChanged: {
            setHighlight (ListItem.selected);
        }
    }
    

    If you begin to feel that this code resembles stamp collector, you something...

    in any case, I stated as follows the data model for the list, copy the following code runs in a callback function SLOT QNetworkAccessManager...

    QList map;QVariantMap variant;foreach (post, posts)
    {
        variant.clear();
        variant.insert("id", post->id);
        variant.insert("title", post->title);
        variant.insert("author", post->author);
        map.insert(map.length(), variant);
    }
    
    ListView *PostsList = mNav->findChild("PostsList");
    
    QListDataModel *model = new QListDataModel;
    model->setParent(this);
    model->clear();
    
    QVariantMap v;
    int i = 0;
    foreach(v, map)
    {
        model->insert(i,v);
        i++;
    }
    
    PostsList->setDataModel(model);
    

    Here is what I expected to happen.

    I compile and debug the program. Some code I have send the network request. I analyze the JSON in a QList (which is my own type). From their I looked in a QList (map, called in the code above). Once I put my ListView data model as the variable according to the guidelines of this line:

    PostsList-> setDataModel (model);

    "PostsList" list updates in the application and displays the data from post-> title, as that inserted in the QVariant inserted in QVariantMap on this line:

    Variant. Insert ("title", post-> title);

    Instead, what is shown is the post-> data of the author, and the only reason I can possible design that is displayed (in reality the point post about 13 members, I removed most of length) is that it is the first in alphabetical order and seems to be the first member of the QVariantMap variable. The author of the message is the unique label presented, so declared both in the QML labels seem to be ignored.

    When I select a list item (by using the code is essentially identical to the example of stampcollector) and page through the QDeclarativeContext method all members of the QVariantMap are accessible and can be used to display items QML.

    Here is an example of how the stamp collector app that performs in the OnSelectionChanged handler:

    ListView* PostsList = dynamic_cast(sender());
    DataModel* Model = PostsList->dataModel();
    
    // Update the content view context property so that it corresponds to
    // the selected item and navigate to the page.
    QVariantMap map = Model->data(indexPath).toMap();
    mQmlContext->setContextProperty("_contentView", map);
    mNav->push(mContentPage);
    

    Can someone explain the behavior that I receive? Why can't I access the articles through the ListItemData.member method as described in the documentation?

    Note: some minor code changes have been made for length and clarity, the code has no compiler errors and like I said the DataModel code works at least to a certain extent all the data members that I expect to be accessible in ListItemData are available in _contentView.

    I haven't checked in depth, but the first thing I would try, is to change your function to return 'post' instead of "item", since you have a component for "post".   I will try an example.

    Stuart

  • How to access the ListItemData of itemType in mode list

    Hi all

    I have a view list and on the basis of itemtype, how do I access the ListItemData.accountNameNo? gives me an error of the function itemType() declared in QML on a ListView must return a string!

    Any help is very appreciated.

    Thanks in advance.

                                listItemComponents: [
                                    ListItemComponent {
                                        type: "accounts"
                                        AccountBox {
                                            id: acc
                                            preferredWidth: 768
    
                                            accNameNo: ListItemData.accountNameNo
                                            label1: ListItemData.label1
                                            input1: ListItemData.input1
                                            label2: ListItemData.label2
                                            input2: ListItemData.input2
                                        }
                                    },
                                    ListItemComponent {
                                        type: "fdAccounts"
                                        FDAccountBox {
                                            preferredWidth: 768
    
                                            accNameNo: ListItemData.accountNameNo
                                            label1: ListItemData.label1
                                            input1: ListItemData.input1
                                        }
                                    }
                                ]
    
                                function itemType(data, indexPath) {
    
                                    if (ListItemType.accountNameNo == "true") {
                                        return "fdAccounts";
                                    } else {
                                        return "accounts";
                                    }
                                }
    

    attaches using the

    var index = dataModel.data (row);
    var name = index.accountNameNo;

  • Custom dialog box could not be shown during the event of 'onCreationCompleted '.

    My application has a 'Warning' dialog box which must be indicated when the application is launched. There are two options in this regard. If users do not accept the warning, the app will be closed. I put it in the onCreationCompleted event handler in the first screen, but it could not be shown there. But I tried to click on a button to open it, it can be displayed correctly.

    I also tried with the dialog system, it can be shown correctly in the event of onCreationCompleted. But I couldn't use it cause my warning dialog box has a complex user interface design.

    attachedObjects: [
        CDialogDisclaimer {
            id: cddisclaimer
        }
    ]
    
    onCreationCompleted: {      try {
            cddisclaimer.open();  //Checked the log, no error, just could not show    } catch (error){        console.log("custom dialog error:"+error.message);    }
    }
    

    Does anyone knows how to fix this?

    Thank you.

    Hello

    It's very strange. Could you try to open it from Manager QTimer onTimer?

    Try to set a large interval first, then, if it works set to 0 msec.

    This page contains a snippet of code to start the timer in QML (search for "QTimer"):

    https://developer.BlackBerry.com/Cascades/documentation/dev/integrating_cpp_qml/index.html

  • ListItemData doesn't have any way to wrap the StandardListItem: description

    Hello

    Someone know how to encapsulate the description from Moel data list item

    For example.  I can view the application Description in the following way

    {StandardListItem}
    Title: ListItemData.appName
    Description: ListItemData.appDescp
    bottomMargin: 50.0
    textFormat: TextFormat.Plain
    }

    but the problem here is that if the 'ListItemData.appDescp' is too long to fit on a single line, that there is no method that can wrap or put the remaining words in the following line

    He simply faints words remaiing which does not fit into the device with.

    Thank you

    Puneet

    You can do one of the following:

    Label{
    
    text: ListItemData.text + ": " + ListItemData.Description
    Multline: true
    }
    
    OR
    
    Container{
    layout: StackLayout{
       orientation: layoutorientation.TopToBottom
    }
    Label{
    //App name
    }
    Label{
    //Description
    }
    
    }
    
  • ListItemData.value returns the undefined value

    Hi guys

    I'm having a weird problem with a ListView.

    I made a custom, based on the sample Image Loader

    My Custom Image Loader class has more variables and several accessors:

        // The accessor methods of the properties
        QVariant image() const;
        QString label() const;
        bool loading() const;
    
        //-- MY ACCESORS
        QString desc() const;
        QString target() const;
        QString title() const;
        etc...
    

    In addition, the example uses a QListDataModel, and in my application, I use a GroupDataModel.

    The following code works. Is my earlier version in which I didn't load the images on the web:

    (lst is a QVariantList loaded from a JSON)

        _dataModel = new GroupDataModel(QStringList() << "porder");
        _dataModel->setParent(this);
    
        //-- insert the JSON data to model
        _dataModel->insertList(lst);
    
        //-- make the model flat
        _dataModel->setGrouping(ItemGrouping::None);
    
        //-- find cascades component of type ListView with an objectName property set to the value 'listView'
        //-- assign data model object (m) to its GUI representation object (list_view)
        if(_listView) _listView->setDataModel(_dataModel);
    
        _dataModel = new GroupDataModel(QStringList() << "porder");
        _dataModel->setParent(this);
    
        //-- insert the JSON data to model
        _dataModel->insertList(lst);
    
        //-- make the model flat
        _dataModel->setGrouping(ItemGrouping::None);
    
        //-- find cascades component of type ListView with an objectName property set to the value 'listView'
        //-- assign data model object (m) to its GUI representation object (list_view)
        if(_listView) _listView->setDataModel(_dataModel);
    

    I tried to fill the list with my custom class by replacing "_dataModel-> insertList (lst);" with this code:

    foreach (QVariant vItem, lst) {
        CustomImageLoader *tempCIL = new CustomImageLoader(vItem.toMap(), this);
        _dataModel->insert(tempCIL);
    }
    

    In other words, the same list that was used in the previous version now is iterated and CustomImageLoaders are created, each contains data in the list.

    The result is a list with the exact number of items, but they are all empty.

    I have connected the properties of tempCIL and they do not contain the same channels from the original list.

    By filling the list with the custom class, in my code QML
    ListItemData.title now returns undefined instead of a string.

    If I print the ListItem ListItemData, it displays an instance of CustomImageLoader.

    I did C++ and QML code very similar to the example of Image Loader, and I can't see what is wrong.

    Advice and pointers are welcome.

    DERP DERP

    I'm not even good to copy

    I missed the Q_PROPERTYs in all

    class CustomImageLoader : public QObject
    {
        Q_OBJECT
    
        Q_PROPERTY(QVariant image READ image NOTIFY imageChanged)
        Q_PROPERTY(QString label READ label NOTIFY labelChanged)
    
        Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged)
    
        Q_PROPERTY(QString desc READ desc)
        Q_PROPERTY(QString porder READ porder)
        Q_PROPERTY(QString target READ target)
        Q_PROPERTY(QString title READ titulo)
        ...
    

    4 hours of pain

  • QML property after onCreationComplete is called?

    Hey all,.

    I try to send an ID of one QML page into another using properties. On the second page, I want to put a list with data corresepoding to the ID that was passed along.

    This is the top of the page that is being created and the

    {Page}
    property alias workoutname: root.workoutName
    property alias workoutid: root.workoutID

    It is the container that contains the list view

    {Of container
    ID: root
    property int workoutID:-1
    "" workoutName variant property:

    It's the onCreationComplete of the Page that has the ID passed in

    onCreationCompleted: {}
    segmentList.dataModel = _Dal.GetListOfWorkoutSegments (root.workoutID);
    }

    The problem is when onCreationComplete is called the root.workoutID is always-1 instead of the value as defined when I created the page?

    Creation of the page below.

    page var = workoutPage.createObject ();
    page.workoutid = id
    page.workoutname = name
    homeNavigationPane.push (page);

    I add these pages through a ComponentDefinition.

    Thank you in advance.

    -J

    It's expected behaviour

    You can do this way:

    page var = workoutPage.createObject ();
    page.workoutid = id
    page.workoutname = name

    page.init)
    homeNavigationPane.push (page);

    .. .and inside yopur page you have a

    function init() {}

    where you can use your properties

  • call the function onCreationCompleted c ++ in qml

    I currently have a problem with the c function call ++ QML.

    Œuvres of normal calls. But when I call a function in onCreationCompleted, he cannot access qml object on the page.

    For example:

    {Page}

    onCreationComplete:

    {myFunction() ;}

    Button {}

    ojbectName: "button1".

    }

    }

    MyFunc access using findChild button1.

    But this return 0 x 0, means the button does not exist.

    So how do I access button1 in c ++ to what page is loaded?

    I have posted from a phone, so sorry if there is no error.

    Look, we can't access the qml object when the page is created (we call it in onCreationCompleted). I bypassed by calling the function after navigationpane.push.

  • Change the pointer to the ListItemData for a ListView

    I have a ListView and a ListItemComponent with a StandardListItem which is currently a local source of Json data.

    I would like to be able to actively change the ListItemData pointer so that I can change the information displayed by my ListView.

         ListView {
                id: myListView
                dataModel: dataModel
    
                listItemComponents: [
                    ListItemComponent {
                        id: listStyles
                        type: "item"
                        StandardListItem {
                            title: ListItemData.name
                            description: ListItemData.description
                        }
                    }
                ]
            } // end of ListView
    

    Looking at the code above, I would change "description: ListItemData.description ' to ' description: ListItemData.status.

    Is this possible? And how would I go to change this? I tried using variants of the property but without any luck so far

    OK, so reuse a single Page, but change the content to adjust the data in the model. Not on a basis of point by point, but just as a 'global '. (Correct me if I'm wrong).

    You could do that. I think there are better ways, but as I probably wouldn't try to do optimization that you apparently, I won't try making it "perfect". Feel free to experiment more. :-)

    // in file SwitchablePage.qml
    import bb.cascades 1.0
    
    Page {
        property alias useDescA: theListView.useDescA
    
        Container {
            ListView {
                id: theListView
                property bool useDescA: true
    
                listItemComponents: [
                    ListItemComponent {
                        id: listStyles
                        type: "item"
                        StandardListItem {
                            title: ListItemData.name
                            description: ListItem.view.useDescA ? ListItemData.descA : ListItemData.descB
                        }
                    }
                ]
        ...
    
    // in file which uses the page
    ...
    
        SwitchablePage {
            useDescA: false  // use descB instead
        }
    

    He took advantage of the somewhat ugly way in which a ListItemComponent can "reach out" in the ListView and access its properties.  Note If you had a custom list item, I think you really need yet another root property on the element in this document, to reach out to the list.  I have the page "reached in ' to the list with an alias property, but you might as well put the property on the page, then have ListView 'out reach' reference with a property alias (for example the property alias useDescA: pageId.useDescA), but it is the same thing I can say.

    I reconsidérerais why you try to do this, but... If it's for performance reasons, I'll make sure that I had measured the impact carefully before going to this effort. I doubt an extra page in another file .qml going to be noticeable by almost any measure, but you could also switch between ListView in a single page or just have several list types ListItemComponent (type for example: 'useDescA' vs type: 'useDescB') and switch between them on this basis. (This would require to implement an itemType() function in the ListView, which would then just return 'useDescA' or 'useDescB', based on some properties.)  This approach looks cleaner in many ways.

Maybe you are looking for

  • How to download icloud on iPhone

    I have an opening statement in iCloud. However, the locations in which it was possible to demonstrate the presentation may have limited/no internet access. Is there a way I can download the Keynote presentation on my iPhone to iCloud so that are stor

  • Windows Update repeatedly offers the KB2565063 update and I can not install

    Repeatedly offered Windows Update is (KB2565063), but when I try to install it continues for long periods of time with no progression of the installation made.

  • Change the Ram in a Lenovo R60

    Hello How can I change RAM in my Lenovo? I'm not sure of the location. Help, please! Bent (Denmark)

  • Bonzi Buddy Setup file.

    Original title: Bonzi Buddy Hello Does anyone have a configuration file for BnoziBUDDY? Please send an email to.

  • Vblock or not VBlock

    Hello I am a newbie of telepresence, so bear with me. Our Intention is to deply complete Immersive telepresence infrastructure in our environment. We have 3 large data centers and the number of remote sites and home users. The intention is to deploy