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");

Tags: BlackBerry Developers

Similar Questions

  • How to send data from the client to the server using tcp

    1. as I am new to watch I need help with sending data from client to server. I went through various examples of labview, but each of them also explains transfer of data to the client server. But I need help regardng send data from the server to the client.

    2.i would use the data type variant for sending my data.

    Can someone help me please. Thank you

    Regardless of the meaning. Once you have a connection each end allows it to send data to another. Just create what you want to look like interaction.

    Do you want the client sends a command that request data?
    How do you think the response data to look like?

    You can send variants, but probably not worth the effort.

    Mike...

  • How to send data from CANOE to LABVIEW

    Hello

    I need to receive data from canoe in Labview.

    I prepared the VI (ex command.vi) sender and receiver VI (Simple UPD - receiver.vi) attached.

    My problem is:

    (1) when I run Canoe (arrested measure) and send the command start-> Canoe starts measurement. (OK)

    (2) when I run VI receiver and send the command Start-> receiver receives the command. (OK)

    (3) when I run the canoe, then run VI receiver and send the command start-> receiver VI receives command but DO NOT canoe starts measurement (canoe does not receive order). (NOK)

    I use the FDX Protocol (UDP-based) and it looks like canoe and receiver VI can work simultaneously on the same port (2809).

    How can I solve this problem?

    PS: Later I want to put the canoe in free run mode to control the Labview application so I need to work VI receiver with canoe.

    OK, now I get it.

    Is there a reason that you need three applications (transmitter + receiver + canoe) at the same time?

    Could not put the sender and receiver in a VI? That would solve your problem of port.

    Another way would be to send messages to general circulation, so canoe and the other VI can receive.

    A third option would be to send the message twice, once at canoe, once the receiver VI.

  • How to send data from the Page with a form to fill out?

    How can I automatically include the page title or any text in my Web page when my client click on the Submit button in a form to fill out?

    This may seem obvious, but if you want to receive data from a form, and then place it in the form. A hidden form field with the title page and the text of your Web page will send these data on the form submission.

    best,

    Shocker

  • How to export data from one Windows a/c to another on the same PC account?

    I had to open a new Windows a/c since my original one would not keep my browsing history despite a number of tweaks and fixes.

    The new account history that is well preserved, BUT how do I export all my data (music, docs... the whole damned much!) of the original a/c to the new?

    Would appreciate any help people!

    Graham

    Hi Graham,

    You can transfer data from the other user account to a new user account by using the article "difficulty a user profile is corrupted.

    Difficulty a user profile is corrupted: http://Windows.Microsoft.com/en-us/Windows7/fix-a-corrupted-user-profile

    Let us know if you need assistance with any windows problem. We will be happy to help you.

  • How to load data from different tables, but record to another table?

    Hi all

    I use the apex and I understand how it updates and saves the files normally.

    In this case, I would need to load from a table, but save on another Board on the button "submit".

    I am aware that it would be easy as forms where I could do a manual insert process. im making in tabular form and I don't really know how to handle this process.

    Suppose that I am loading a set of questionnaires in the form of tables and have a yes / no selection.

    If the questions would come from table A and I need to save it in table B.

    in this case that I can't put just the value default by the tabular row for questions coz it would be dynamic and this example is on a small scale. I would need to load the table A and record in table B.

    could someone guide me on this operation or provide tutorials any?

    Maybe that's what you're after.

    (1) create region report using SQL like this:

    Select apex_item.hidden(1,rownum).

    apex_item.display_and_save(2,question_column) in Question,

    apex_item. Text(3,,4,4) as answer

    from table_a

    apex_item documentation of package found:

    http://docs.Oracle.com/CD/E37097_01/doc/doc.42/e35127/apex_item.htm

    The pidx (first number) in each apex_item parameter is used to identify this item in the same row of the report' / tabular form.

    (2) create a submit in procedure a bit like that.

    Start

    because I 1.apex_application.g_f01.count loop - identifies the "apex_item.hidden(1,rownum)" at the top and gets a count of how many times it occurs

    Insert into table_b (question, answer)

    values (apex_application.g_f02 (i), apex_application.g_f03 (i));

    end loop;

    end;

  • How to send data from 150 morethen FlashVars

    Hello

    I need to send the data to flashvars, size is more then 150kb. This data set will be created by javascript.

    Thanks in advance.

    Chavigny

    use a return in your js function to return data to actionscript.

    You can use a timer loop to repeatedly query the js function and check whether the data is available.  When this is the case, put an end to the loop and use the data.

  • How to send data from the GET method?

    Dear all,
    I am trying to send a value list to a web server. Add the function to determine the value, I do not have here. The method I use is as below. I would like to know how is the value of the shipment to the web server that is the form of http://mysite:8080/test1/test1.aspx?myMessage=outputToServer. How to achieve this format?


    Try
    {
    URL url = new URL ("http://mysite:8080/test1/test1.aspx"); ")
    HttpURLConnection connection = () (HttpURLConnection) url.openConnection;
    connection.setDoOutput (true);
    connection.setRequestMethod ("POST");
    OutputStreamWriter writer = new OutputStreamWriter (connection.getOutputStream ());

    If (connection.getResponseCode () is HttpURLConnection.HTTP_OK)
    {
    Writer.Write ("myMessage =" + outputToServer);
    Writer.Close ();
    }
    on the other
    {
    System.out.println ("connection not found :");
    }
    }
    catch (MalformedURLException e)
    {
    System.out.println ("MalformedURLException");
    }
    catch (IOException e)
    {
    System.out.println ("IOException");
    }

    Remove anything to do with the writer.

  • How to extract data from SQL server in the FDM

    Hi Experts

    How to extract data from a SQL server HFM to another SQL Server using scripts for integration in FDQM?

    concerning

    Dev

    Could you clarify why you want to do this?

    If you try to synchronize two databases (apps) to have a backup or something running in a development environment, I suggest configuring replication between two databases. It would be much more effective to do it at the SQL Server level through the application of FDM, IMHO.

    Charles

  • Send with blackBerry Smartphones, how to retrieve data from blackberry?

    Hi, I need to send an email to blackberry and on the user's response, I need to store this data in the database. Can u please help me in this regard. How to send email from web browser, and then retrieve the data in a database.

    khushi289 wrote:
    OK ya... We use Tomact 6. How do you after that

    It is a forum oriented BlackBerry technology, you have questions about web development. I think it's best for you is to find some tutorials on the internet on "how to create a web application on tomcat with a database" or try a forum oriented Tomcat directly.

  • How to transfer data from USB key

    How to transfer data from the reader flash player (C), when you open send it to it does not have this option

    Drag & drop.

  • How to erase data from the iphone if I lost and iphone is offline

    How to erase data from the iphone if I lost and iphone is offline

    < post branched out by host >

    Hello

    What to do if your iOS device is turned off or offline?

    If your missing device is turned off or offline, you can still implement this Mode lost, lockor remote wipe. The next time your device is online, these measures will take effect. If you remove the device from your account while it is offline, pending actions for the device will be cancelled.

    If your iPhone, iPad or iPod touch is lost or stolen - Apple supports

  • How to delete data from the iPhone 5 c?

    How to remove data from my iPhone 5 c?

    What do you mean by data? Applications, photos, music??  It depends on what you're trying to delete.

  • How to transfer data from a mac mini in 2006 for a new?

    How to transfer data from a mac mini in 2006 for a new?

    The following can help:

    Move your content to a new Mac - Apple Support

    OS X: manually the Data Migration from another Mac - Apple Support

  • How to transfer data from my computer to a new phone

    How to transfer data from my computer/Itunes to a new device? I downloaded all my data from an Iphone 4 on my computer and I wonder how to transfer all of these data to an Iphone 5 that I own. I need to my emails and text messages transfer too. Any ideas? Email that I have Setup with my phone is an email from work, so it is important that I do not lose one of them.

    You must put all your media files in iTunes. Synchronize your phone using iTunes.

    iTunes - Apple Support

    iPhone - Apple Support

Maybe you are looking for