QML QVariantList QString Converter?

Hey all

I'm relatively new to programming of BB. I have some experience in Android and Windows Phone, but I think that BB10 will kick a lof of * beep *!

I did a bit of programming for my application and I use a Web service to download the json from the server data. Now, I have programmed a view master / detail with qml, when clicking on an item in the list, I get the details of this item.

But the article also has QVariantLists because it is a data table. For example, in my json file, I have the language of property: ['Dutch', 'English', 'French'].

Now, I want to show these multiple languages in my detailpage. Is it possible to write a converter or something like that? Or should I do the treatment before you add data to my datamodel?

Thanks in advance!

QVariant-s work just like the javascript in QML tables.
If you know how to access this QML QVariantList, you can also iterate through it the addition of all the members of a chain.

var s = "";
for (var i = 0; i < myList.length; i++) {
 console.log(myList[i]);

 if (i != 0)
   s += ", ";
 s += myList[i];
}

Tags: BlackBerry Developers

Similar Questions

  • QML/C++ call problem

    Hey guys. Looking for a little help here. I know that this problem has been addressed before, but I'm a little lost. I have searched the forums and looked through the tutorials, but I havn't been able to find the answer I was looking for. I'm calling a simple C++ function of my UI QML/waterfalls and it won't work. The problem I have is I've seen code snipets where people have solved their problems with this, but nothing as an explanation as to what or why of it. In any case, here are a few snippets, please tell me what I'm missing here.

    Main.qml// Default empty project template
    import bb.cascades 1.0
    
    // creates one page with a label
    // The button was added by me to change the text of the label
    
    Page {
        Container {
            layout: DockLayout {}
            Label {
                id: label1
                text: qsTr("Huh?")
                textStyle.base: SystemDefaults.TextStyles.BigText
                verticalAlignment: VerticalAlignment.Center
                horizontalAlignment: HorizontalAlignment.Center
            }
            Button {
                text: "Say Hi..."
                onClicked: { label1.text=HelloWorld.returnMyString(); //Works perfectly if written label1.text="Hello World";
    
                }
            }
        }
    }
    
    HelloWorld.cpp
    
    // Default empty project template
    #include "HelloWorld.hpp"
    
    #include 
    #include 
    #include 
    
    using namespace bb::cascades;
    
    HelloWorld::HelloWorld(bb::cascades::Application *app)
    : QObject(app)
    {
        // create scene document from main.qml asset
        // set parent to created document to ensure it exists for the whole application lifetime
        QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    
        // create root object for the UI
        AbstractPane *root = qml->createRootObject();
        // set created root object as a scene
        app->setScene(root);
    }
    
    //The only thing I added to the file was this function
    QString HelloWorld::returnMyString()
    {
        return ("Hello World");
    }
    
    HelloWorld.hpp
    
    // Default empty project template
    #ifndef HelloWorld_HPP_
    #define HelloWorld_HPP_
    
    #include 
    
    namespace bb { namespace cascades { class Application; }}
    
    /*!
     * @brief Application pane object
     *
     *Use this object to create and init app UI, to create context objects, to register the new meta types etc.
     */
    class HelloWorld : public QObject
    {
        Q_OBJECT
    public:
        HelloWorld(bb::cascades::Application *app);
        virtual ~HelloWorld() {}
    
        //Added the ability to invoke the function from QML
        Q_INVOKABLE QString returnMyString();
    };
    
    #endif /* HelloWorld_HPP_ */
    

    I don't know what I'm missing here. What I read in other posts, I had what seems to be correct, but if I call it as I wrote, then the feature apparently never gets called and nothing happens. I don't get the error while compiling codes and it works on the SIM perfectly, except for the inability to call the C++ function.

    If you guys can give me some guidance, I think I could really off and running with my real application coding. I know that there must be something stupid that I'm missing.

    Thank you guys!

    Hello

    You must give your qml know your c++ as follows object before accessing an object c ++ QML.

    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);qml->setContextProperty("HelloWorld",this);
    

    MAZ

  • QVariantMap passage of QML

    I need to fill a QVariantMap with values, QML, and then pass to a C++ function, like this:

    QVariantMap map;
    map["type"] = type;
    map["date"] = strDate;
    map["value"] = value;
    map["unit"] = unit;
    _app.addItem(map);
    

    How to achieve this in QML? Is there a QVariantMap or equivalent type that will allow me to do in QML?

    Thank you!

    I expect the QML engine to convert a regular JavaScript 'object' of a QVariantMap when you switch to a C++ function. Just try with _app.addItem ({type: type, day: strDate, value: value, unit: Unit}) and see what he does.

  • GroupDataModel how to search for an item and row

    Hi all!

    I have a problem with GroupDataModel.

    I create and fill out the template as below:

    
    m_model = new GroupDataModel(QStringList() << "displayName", this);
    ...
    QVariantMap entry;
    entry["contactId"] = QString::number(contact->getId());
    entry["displayName"] = contact->getDisplayName();
    entry["icon"] = contact->getSmallPhoto();
    
    m_model->insert(entry);
    

    After I cath some report like contactDeleted (int id) and want to remove the related item of the model:

    void ContactsViewModel::onContactDeleted(int id)
    {
      //QVariantList indexPath = m_model->lowerBound(QVariantList() << QString::number(id));
      //QVariantList indexPath = m_model->lowerBound(QVariantList() << id);
      //QVariantList indexPath = m_model->find(QVariantList() << QString::number(id));
      QVariantList indexPath = m_model->find(QVariantList() << id);
    
      if (!indexPath.isEmpty())
      {
        m_model->removeAt(indexPath);
      }
    }
    

    But model will always return row to the first article! I used and GroupDataModel::find and GroupDataModel::lowerBound, but result is still the same!

    Please help me, how can I find point correct?

    Hello

    My understanding of the documentation, it is possible to search only the fields that are in sortingKeys.

    I think that GroupDataModel is the construction of indexes on these areas.

    I did some tests:

    If displayName is present in sort keys:

        GroupDataModel *model = new GroupDataModel(QStringList() << "displayName", this);
    
        QVariantMap entry;
        entry["contactId"] = "100";
        entry["displayName"] = "Alex";
        entry["icon"] = "icon1.png";
        model->insert(entry);
    
        entry["contactId"] = "200";
        entry["displayName"] = "Andrew";
        entry["icon"] = "icon2.png";
        model->insert(entry);
    

    then by displayName will work correctly:

    QVariantList indexPath = model->find(QVariantList() << "Andrew");
    qDebug() << "indexPath" << indexPath << "\n";
    // this will print (QVariant(int, 0) ,  QVariant(int, 1) ) which is
    // section 0, item 1
    

    But research by contactId won't work, because it is not present in sortingKeys.

    If you add contactId to sortingKeys:

    GroupDataModel *model = new GroupDataModel(QStringList() << "displayName" << "contactId", this);
    

    then by searching only by displayName will no longer work. Find() maps values to keys, it will only return entries with empty contactId. But lowerBound() can be used instead:

    QVariantList indexPath = model->lowerBound(QVariantList() << "Andrew");
    qDebug() << "indexPath" << indexPath << "\n";
    // this will return:
    // indexPath (QVariant(int, 0) ,  QVariant(int, 1) )
    

    Please note that the lowerBound is not a complete replacement for find. It returns a suggested for element insertion index. So if she is unable to find a match, it will return (0, 0) like suggested insertion point, but not a row empty.

    When you have multiple sort keys the code depending on type of work to find a name:

        GroupDataModel *model = new GroupDataModel(QStringList() << "displayName" << "contactId", this);
    
        QVariantMap matchMap;
        //matchMap["contactId"] = "200";
        matchMap["displayName"] = "Andrew";
        QVariantList indexPath = model->lowerBound(matchMap);
        qDebug() << "indexPath" << indexPath << "\n";
    

    But if the name is not found lowerBound will return (0, 0) - a proposed insertion point. Is not possible to differentiate the value of return "not found".

    But if you try to provide a contactId

        matchMap["contactId"] = "200";
        //matchMap["displayName"] = "Andrew";
    

    It will not work, because it searches in the order in which the sortingKeys have been reported.

    In this case, it will try to 'empty' QVariant DisplayName of match, find nothing and will be (0, 0) return as insertion point proposed without even trying to match contactId-s.

    The find() function is not appropriate as well because it performs the exact match on all fields and requires that all sortingKeys to be defined.

    I hope I have not confused you completely now!

    So, the conclusion seems to be:

    Find() cannot find an exact match and compared all the keys of the supplied with keys in sortingKeys. If values are omitted it is expected that they are NULL in the model.

    lowerBound() returns a suggested insertion or (0, 0) point, if nothing has been put in correspondence. He compares the values passed to it with the sort of keys from left to right (if the first sortingKey did not match it does not compare).

    If these methods are not well suited for finding a specific key value. A possible workaround is an iteration model entries manually and by comparing their values, but it's slow.

    I suggest to create your own datamodel by inheriting from the class DataModel. It is not very difficult, and you can implement any kind of search in there.

  • Convert int value of sql in QString without using C++

    Hi, I'm having trouble passing an integer value in my list. I am entirely dependent on QML and would rather not touch C++ because they tend to create more problems for me sometimes.

    I need to load some data such as: Int ID, string directory in my GroupDataModel.

    It is:

    (1) I use the ID as a sort key

    AND

    (2) I want to display on my list as well.

    I found another solution that calls for the values to store them as "001, 002, 003," etc, but as I mentioned, I would like to view the information and is not sustainable.

    I wonder if maybe I can use javascript to convert this string? I tried to look for Qt btu solutions, they are all highly dependent on C++ and I do not want to touch that.

    I tried:

     function convertInt (data){return QString(%1).arg(ListItemData.CategoryID || "")}
    

    But it doesn't seem to work at all...

    I also tried ListItemData.CategoryID.toString () but it does not work as well...

    Can someone please? Thank you!

    After hours of trial and error, I finally managed to get CategoryID show.

    Instead of referring to him as ListItemData.CategoryID, I just used: ListItemData under the heading ListItemComponent.

    I also deleted the itemType function because it does not seem necessary here atm.

    Apparently it's kind of 'automatic' putting in the CategoryID in the sortingKeys and grouping.

  • QVariantList gives QString int not

    Hey there

    You have a problem with my QVariantList.

    When I do

    QSettings settings(author, appName); 
    
    if(settings.value("days").isNull()) {
        QVariantList list;
        for(int i = 1; i < 6; i++)
            list.append(i);
        settings.setValue("days", list);
    }
    qDebug() << "initialize: "<< settings.value("days").toList();
    

    He said: initialize: (QVariant (QString, '1'), QVariant (QString, '2'),...)

    But I do of the economies of the int, am I right?

    I need to record the first 5 days to a week.

    The user can select them in a dialog box. The first 5 days are the default.

    When today is in those selected, my headless service did something

    Are you sure?

    By

    if( settings.value("days").toList().contains(
    QDate::currentDate().dayOfWeek() )
      )
    

    I check, if today is one of the days of qsettings.

    Before I changed some of my Code it worked that way.

    Wired-. -.

    I solved it by using QString::number(QDate::currentDate().dayOfWeek())

    I personally would say that it is a workaround

    but in any case, thank you

  • How to pass a QString QML to C++

    Hello

    How can I pass a QString QML to C++ and add it to a list view. Here's the code that describes my problem.

    I have a mainpage that contains a list view:

    // applicationui.cpp[...]void ApplicationUI::initFullUI() {
    
        QmlDocument *qml = QmlDocument::create("asset:///Main.qml").parent(this);
        qml->setContextProperty("app", this);
    
        // Create root object for the UI
        AbstractPane *root = qml->createRootObject();
    
        ArrayDataModel *model = new ArrayDataModel;
    
            if(------------->*\ file selected from qml /*<---------------){
              model->append(------------->*\String from QML/*<---------------);
            }    // Connect to list view and update modal
        ListView *listView = root->findChild("listview");
        listView->setDataModel(model);
    
        Application::instance()->setScene(root);
    }
    

    The string I want C++ comes from the filepicker on the main.qml

    // main.qml[...]attachedObjects: [
                FilePicker {
                    id: filePicker
    
                    property string selectedFile
    
                    mode: FilePickerMode.Picker
    
                    type: FileType.Other
                    title: "Open file..."
                    viewMode: FilePickerViewMode.Default
                    sortBy: FilePickerSortFlag.Default
                    defaultType: FileType.Other
                    onFileSelected: {
                        console.log("FileSelected signal recieved : " + selectedFiles);
                        selectedFile = selectedFiles[0];
                    }
                }
            ]
    

    Now, I did C++ functions to save the string:

    // Document.hppclass Document: public QObject {  Q_PROPERTY(QString document READ document WRITE setDocument NOTIFY documentChanged)
    
    public:  Q_INVOKABLE QString document();  Q_INVOKABLE void setDocument(QString &document);
    
    private:  QString m_document;}
    
    // Document.cpp
    
    QString Document::document(){
        return m_document;
    }
    
    void Document::setDocument(const QString &document){    if(document != m_document) {            m_document = document;            emit documentChanged(m_document);        }}
    

    Is this possible with this how to complete the string in the list view? Also how to make C++ know that the format was chosen among the filepicker so that it can add a new item to the list?

    Or do I have to go another way (for example by writing also the filepicker entirely in C++)?

    Here is an example, it uses a button rather than the FilePicker, but the mechanism is the same...

    Button {
        property int count: 0
        text: "Add item"
        onClicked: {
            count++
            theDataModel.append("button click " + count)
        }
    }
    
    ListView {
        dataModel: ArrayDataModel {
            id: theDataModel
        }
    
        [ ... ]
    }
    
  • How to convert the &lt; Contact &gt; QLIST Qstring

    Hello

    I would like to send my contacts from the device to the server using the Soap web service. but the method which who sent the item on the server takes the QString parameter and the contacts which I am retriving are type QLIST then please suggest me a method that converts the QList QString.

    Help, please...

    QString has a constructor that accepts a QByteArray.

  • How to convert a QString in full

    Here, I want to do some calculations on the user to input so iam takeing user using textfield using the function text() but he returned QString then how to convert QString in full

    Hi, have you tried toInt()?

    http://doc.Qt.Digia.com/latest/QString.html#toInt

  • QList &lt; QString &gt; values of the RPC return as "not defined" in QML

    Hello. I have a pretty simple question. In my qml file calling a what function of the applicationui.cpp file which is below:

    QList ApplicationUI::getList() {
        qDebug() << myMap.keys(); // prints ("key1", "key2")
        return myMap.keys();
    }
    

    In my file QML (sheet), I write the code below:

        onOpened: {
            var myKeys = app.getList();
            console.log(myKeys); // prints undefined
            for (var item in myKeys){
                myDataModel.append(myKeys[item]);
            }
        }
    

    As you can see in the code, when the program comes to expression qDebug ("key1", "Key2") it prints but it's the expression of console.log (myKeys), it prints "undefined". I'm definitely something wrong. Could you please help?

    Try to send the QList instead. This should make happy qml

  • Convert a Contact to a QVariant in a list

    Hey. Since I'm still pretty new to c ++ my understanding of the collocation of type is incomplete. I need to get my Contacts QList into a QVariantList, so I can put it in the constructor of a QListDataModel for use in a ListView. I can't get my Contact to convert a QVariant. Here's the code. I also tried to convert a Contact or a Contact * in a QVariant without success.

    Enjoy your time,

    See you soon
    Justin D.

    Q_DECLARE_METATYPE(Contact);
    Q_DECLARE_METATYPE(std::list);
    
    ///////////////////////////////////////////////////
    
        if (partial.length() < 3)
            return;
    
        QString completed = partial;
    
        ContactAutoCompleteSearchFilters cacsf;
        cacsf.setLimit(5);
        cacsf = cacsf.setIncludePhotos(true);
        cacsf = cacsf.setSearchField(SearchAutoCompleteField::Email);
        cacsf = cacsf.setSearchValue(partial);
    
        ContactService cs;
    
        qRegisterMetaType("Contact");
    
        QList ql = cs.searchContactsAutoComplete(cacsf);
        std::list l = ql.toStdList();
        QVariantList qvl = QVariantList::fromStdList(l);   /// <<<<< Error, No matching function for call
    

    QVariant supports a limited set of objects. But one of them is QObject *, which allows to use
    qVariantFromValue(objectPointer)

    Now the second question would be if the implementation of Contact can be used in QML (saved successfully). I have not tried, but if it does not, you will need to write your own wrapper class that returns the properties that you need, for example using Q_PROPERTY.

  • QString Param passing curl - C++, type the question?

    What I try to do

    Pass a QString to a C++ method. The method is effective QML.

    My Code

    applicationui.cpp

    // Default empty project template
    #include "applicationui.hpp"
    
    #include 
    #include 
    #include 
    #include 
    
    #include 
    #include 
    
    #include 
    #include 
    
    using namespace bb::cascades;
    using namespace bb::system;
    //new to text message
    
    ApplicationUI::ApplicationUI(bb::cascades::Application *app)
    : QObject(app)
    {
        // create scene document from main.qml asset
        // set parent to created document to ensure it exists for the whole application lifetime
        QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
        // create root object for the UI
        AbstractPane *root = qml->createRootObject();
        qml->setContextProperty("_app", this);
        // set created root object as a scene
        app->setScene(root);
    }
    
    void ApplicationUI::routeQuery(QString query)
    {
         CURL *curl;
          CURLcode res;
    
          curl = curl_easy_init();
          if(curl){
            curl_easy_setopt(curl, CURLOPT_URL, "http://google.com/search?q="+query);
            /* example.com is redirected, so we tell libcurl to follow redirection */
            curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
    
            /* Perform the request, res will get the return code */
            res = curl_easy_perform(curl);
            qDebug() << res;
            qDebug() << "making query";
    
            /* Check for errors */
            if(res != CURLE_OK)
              fprintf(stderr, "curl_easy_perform() failed: %s\n",
                      curl_easy_strerror(res));
          }
            /* always cleanup */
            curl_easy_cleanup(curl);
    }
    

    applicationui. HPP

    // Default empty project template
    #ifndef ApplicationUI_HPP_
    #define ApplicationUI_HPP_
    
    #include 
    #include 
    #include 
    #include 
    #include 
    
    namespace bb { namespace cascades { class Application; }}
    
    /*!
     * @brief Application pane object
     *
     *Use this object to create and init app UI, to create context objects, to register the new meta types etc.
     */
    class ApplicationUI : public QObject
    {
        Q_OBJECT
    public:
        ApplicationUI(bb::cascades::Application *app);
        virtual ~ApplicationUI() {}
        Q_INVOKABLE void routeQuery(QString query);
    };
    
    #endif /* ApplicationUI_HPP_ */
    

    hand. QML

    import bb.cascades 1.2
    import bb.system 1.2
    
    Page{
    Container{
    layout: StackLayout{
        orientation: LayoutOrientation.TopToBottom
    }TextField{   id: userQuery   text: ""   hintText: "Enter your search..."}
    Button{
         text: "Route"
         onClicked: {
             _app.routeQuery(userQuery.text);
          }
         }
    
    }
    }
    

    Errors / question

    The issue is the line where I spend the "query" in the url for google. Here's what says the error:

    cannot pass objects of type trivially uncopyable ' class const QString "by «...» »

    Notes
    - QString - BBDOC

    - Integration of QML/C++ - BBDOC

    - Example of C++ Curl Simple HTTP (curl.haxx.se)

    Been stuck on this day. Please help if you can get this to work.

    Hello

    Libcurl is probably waiting for style C UTF8 string Qt strings are UTF16

    This product code QString:

    "http://google.com/search?q=" + query
    

    Try this conversion:

    curl_easy_setopt(curl, CURLOPT_URL, ("http://google.com/search?q=" + query).toUtf8().constData());
    

    . toUtf8() converts QString QByteArray UTF8.

    . constData() returns const char *.

  • Another Question for C++ question QML class

    Hello

    I have a class that I joined in QML. I have a couple of Q_PROPERTY int and QString. Now I would like to spend a lot of information to the QML which includes data elements. I would spend the entire data group from the C++ QML and then have easy access to data elements.

    I was wondering what the best structure to allow that load the structure in C++ and access the items in the QML.

    Thanks in advance.

    Just thought that I would finalize the solution that worked and marks it as such.

    all

    class PData::PData(QObject* parent) {
    
      Q_PROPERTY(QVariantList pData READ pData NOTIFY pDataChanged)
    public:
      QVariantList pData();
    
    signals:
      void pDataChanged();
    private:
      QVariantList m_pData;
    

    .cpp

    QVariantList PClass:pData()
    {
      return m_pData;
    }
    void function() {
      QVariantMap tMap;
      tMap["t1"] = 1;  tMap["t2"] = 2;
      m_pData.append(tMap);  emit pDataChanged();}
    

    . QML

    onPDataChanged: {
      var pItem = myPData.pData;  var dataMap = pitem[0];  var t1 = dataMap["t1"];  var t2 = dataMap["t2"];
    }
    
    attachedObjects: [  PData {    id: myPData  }]
    

    Thanks to all who helped.

  • How to extract the value of QVariantlist

    Hello

    I was trying to understand quoteapp example to implement the sqldata in my application. In this example, they are passing all qvariantlist in groupdatamodel and use it in listview. But I don't want to use listview and want to access the value of a particular column in a table on a page. Anyone can guide me please how?

    I'll try to explain what I did to understand how it works. If you have QVarint or QVariantList, right? So now, print it in console with qDebug().

    You will see something like this.

    QVariant(QVariantMap, QMap(("StationButton", QVariant(QString, "") ) ( "StationButtonSelected" ,  QVariant(QString, "") ) ( "StationIcon" ,  QVariant(QString, "0332.jpg") ) ( "StationName" ,  QVariant(QString, "JD Inside") ) ( "StationStreamURL" ,  QVariant(QVariantMap, QMap((".data", QVariant(QString, "http://www.panel-streaming.com/tunein.php/jdinside/playlist.pls") ) ( "type" ,  QVariant(QString, "pls") ) )  ) ) ( "StationURL" ,  QVariant(QString, "http://www.jdinside.com/") ) )  )
    

    So now if I would get Station stream URL type I need to do the following

    QString currType = data.valueQVariantMap>.value("__StationStreamURL__").value ()QVariantMap> ()QString.value("t__ype__").value > ();

    As you can see the first structure is QVariantMap, so we use data.velue() to get it. Then is StationStreamUrl, as QVariantMap and we can get type and convert it to QString. It's something like cabbage, where you need to remove all the layers.

    It will be useful. If not give me what structure you have and I'll try to help you.

    Thank you.

  • How to send data from c ++ to qml to an another qml.

    Hello

    I'm quite confused about a simple problem, I'm sure. Let me put some of my code and then I'll ask my question

    hand. QML

    // Default empty project template
    import bb.cascades 1.0
    import bb.data 1.0
    
    // creates one page with a label
    
    TabbedPane {
        Menu.definition: MenuDefinition {
            actions: [
                ActionItem {
                    title: "Refresh"
                }
            ]
        }
        showTabsOnActionBar: true
        Tab {
            title: qsTr("Employee")
            NavigationPane {
                id: everyonePane
                Page {
                    id: everyoneFeed
                    ListView {
                        objectName: "FeedView"
                        id: FeedView
    
                        layout: StackListLayout {
                            headerMode: ListHeaderMode.Sticky
                        }
                        listItemComponents: [
                            ListItemComponent {
                                type: "item"
                                DetailFeed {
                                }
                            }
                        ]
                    }
                }
                attachedObjects: [
                    ActivityIndicator {
                        objectName: "indicator"
                        verticalAlignment: VerticalAlignment.Center
                        horizontalAlignment: HorizontalAlignment.Center
                        preferredHeight: 200
                        preferredWidth: 200
                    }
                ]
                onCreationCompleted: {
    
                }
            }
        }
        Tab {
            title: qsTr("TimeSheet")
            Page {
            }
        }
        Tab {
            title: qsTr("Calendar")
            Page {
            }
        }
    }
    

    detailView

    import bb.cascades 1.0
    
    Container {
        layout: StackLayout {
            orientation: LayoutOrientation.TopToBottom // this line stacks everything below
        }
        bottomPadding: 20
        Container { // single row
            id: row1
            // individual row container
            layout: DockLayout {
            }
            preferredWidth: maxWidth
            Container { // container for image
                preferredWidth: 150 //size of image if known
                preferredHeight: 150
                topPadding: 10
                leftPadding: 20
                horizontalAlignment: HorizontalAlignment.Left
                verticalAlignment: VerticalAlignment.Center
                ImageView {
                    preferredWidth: 150 //size of image if known
                    preferredHeight: 150
                    imageSource: "asset:///images/person.jpg" // some image
                }
            }
            // stack labels
            Container { // container for labels
                horizontalAlignment: HorizontalAlignment.Left // align this container to the left
                translationX: 200
                verticalAlignment: VerticalAlignment.Center
                layout: StackLayout {
                    orientation: LayoutOrientation.TopToBottom // this stacks the labels
                }
                Label {                objectName: "firstname"
                    text: "first label"
                }
                Label {
                    text: "second label"
                }
            }
        }
        Divider {
        }
    }
    

    Employee.cpp

    // Default empty project template
    #include "Employee.hpp"
    
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    
    #include 
    #include 
    
    using namespace bb::cascades;
    
    QString mQueryUri;
    
    Employee::Employee(bb::cascades::Application *app) :
            QObject(app) {
        // create scene document from main.qml asset
        // set parent to created document to ensure it exists for the whole application lifetime
        mQml = QmlDocument::create("asset:///main.qml").parent(this);
    
        // create root object for the UI
        mRoot = mQml->createRootObject();
    
        // Retrieving my activity indicator
        //mActivityIndicator = mRoot->findChild("indicator");
        //mActivityIndicator->start();
    
        // Retrieving my list from QML
        mListView = mRoot->findChild("dribbbleFeedView");
        GetFeed("everyone");
    
        // set created root object as a scene
        app->setScene(mRoot);
    }
    
    void Employee::GetFeed(QString feedType) {
        // First off we initialize our NetworkManager
        QNetworkAccessManager* netManager = new QNetworkAccessManager();
        if (!netManager) {
            qDebug() << "Unable to create QNetworkAccessManager!";
            emit complete("Unable to create QNetworkAccessManager!", false);
            return;
        }
    
        // First off we initialize our NetworkManager
        netManager = new QNetworkAccessManager();
        if (!netManager) {
            qDebug() << "Unable to create QNetworkAccessManager!";
            emit complete("Unable to create QNetworkAccessManager!", false);
            return;
        }
    
        mQueryUri = "http://mycompany" + feedType;
        // We setup our url
    
        QUrl url(mQueryUri);
        QNetworkRequest req(url);
    
        // Setup the reply and connect to the reply function
        QNetworkReply* ipReply = netManager->get(req);
        connect(ipReply, SIGNAL(finished()), this, SLOT(onReply()));
    }
    
    void Employee::onReply() {
        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;
                    Q_UNUSED(read);
                }
            } else {
                response =
                        QString("Error: ") + reply->errorString()
                                + QString(" status:")
                                + reply->attribute(
                                        QNetworkRequest::HttpStatusCodeAttribute).toString();
                qDebug() << response;
            }
            reply->deleteLater();
        }
        if (response.trimmed().isEmpty()) {
            response = "Request failed. Check internet connection";
            qDebug() << response;
        }
    
        bb::cascades::GroupDataModel* dm = new bb::cascades::GroupDataModel(
                QStringList() << "id");
    
        dm->setGrouping(bb::cascades::ItemGrouping::None);
    
        // parse the json response with JsonDataAccess
        bb::data::JsonDataAccess ja;
        QVariant jsonva = ja.loadFromBuffer(response);
    
        QVariantList feed = jsonva.toMap()["employee"].toList();
    
        QVariantMap player;
    
        foreach (QVariant v, feed)
        {
            QVariantMap feedData = v.toMap();
            dm->insert(feedData);
        }
    
        mListView->setDataModel(dm);
        mListView->setVisible(true);
    }
    

    OK so here is my question. I load a listview, in my hand, calling another qml, detailview. Given that my PPC is load my json file how can I send what I receive in my datamodel in my detailfeed can I change we tell the label with objectName: "firstname" to change the text for datamodel.name?

    Hope I am clear enough.

    Thank you

    I think that you can access ListItemData in detailView.qml. Say ListItemData.id.

    Why do you add only a mapping in groupdata. I think you need to add all the necessary fields such as firstname and so on. Right?

    bb::cascades::GroupDataModel* dm = new bb::cascades::GroupDataModel(
                QStringList() << "id");
    

Maybe you are looking for

  • Satellite 1400 enters standby after 30 minutes when it is not in use

    Hey all. I just installed a module of 256 MB of RAM, so I now 384 of RAM. He moved, the computer between stand-by mode after about 30 minutes when it is not being used. I tried to change the power management settings, but when I click on power manage

  • Apps battery saver

    Did someone using our tried all the apps battery saver. I was reading the comments of the battery saver and they appear to be positive, I just never tried this type of app before.

  • Laptop does not connect to Wifi

    I have an Inspiron 17r, and I sometimes has incredible problems of Internet connection. Anything else in my house can work very well, but my computer is unable to connect, need help that I have no idea what to do.

  • Error code 0 x 644, when you try to download KB951847 Service Pack for Windows XP

    Priority update "Microsoft.NET Framework 3.5 Service Pack 1 and the .NET Framework 3.5 Family Update for versions of .NET 2.0 to 3.5 (KB951847) x 86", Windows XP (with Office 2003), a failure to install message appears with the error code 0 x 644. It

  • OfficeJet Pro 6830: Question about drying of ink on Officejet Pro 6830

    Hello I have to buy a new HP printer for my parents. In fact, they use a hp photosmart 3300 and it will print no more. I have met a few cleanup step, but now nothing. So decided to buy a new one and I'm interesting by a Pro Officejet 6830. Why, becau