A simple example of filling the data from Json to a ListView.

I want a simple example to inflate a listview with Json data.

Examples of the sample do not work

as we have a code example

App.cpp

App::App()
{
    Page *root = new Page;
    ListView *listView = new ListView;

    // Create the data model, specifying sorting keys of "firstName" and "lastName"
    GroupDataModel *model = new GroupDataModel(QStringList() << "firstName"
                                               << "lastName");

    // Create a JsonDataAccess object and load the .json file. The QDir::currentPath()
    // function returns the current working directory for the app.
    JsonDataAccess jda;
    QVariant list = jda.load(QDir::currentPath() +
                             "/app/native/assets/employees.json");

    // Insert the data into the data model. Because the root of the .json file is an
    // array, a QVariant(QVariantList) is returned from load(). You can provide a
    // QVariantList to a data model directly by using insertList().
    model->insertList(list.value());

    qDebug()<<"the size of model is "<size()<<"\n";

    // Set the data model for the list view
    listView->setDataModel(model);

    // Set the content of the page and display it
    root->setContent(listView);    Application::setScene(root);
}

with the file employees.json of assets

[
    {
        "firstName" : "Mike",
        "lastName" : "Chepesky"
        "employeeNumber" : 01840192
    },
    {
        "firstName" : "Westlee",
        "lastName" : "Barichak"
        "employeeNumber" : 47901927
    },
    {
        "firstName" : "Jamie",
        "lastName" : "Lambier"
        "employeeNumber" : 51239657
    },
    {
        "firstName" : "Denise",
        "lastName" : "Marshall"
        "employeeNumber" : 41239520
    },
    {
        "firstName" : "Matthew",
        "lastName" : "Taylor"
        "employeeNumber" : 01963597
    },
    {
        "firstName" : "Mark",
        "lastName" : "Tiegs"
        "employeeNumber" : 65321951
    },
    {
        "firstName" : "Karla",
        "lastName" : "Tetzel"
        "employeeNumber" : 03266987
    },
    {
        "firstName" : "Ian",
        "lastName" : "Dundas"
        "employeeNumber" : 29472012
    },
    {
        "firstName" : "Marco",
        "lastName" : "Cacciacarro"
        "employeeNumber" : 56446691
    }
]

On the run, it shows a white screen with no list control.

Thank you all for your answers, actually problem was not in the code. The problem is in the employees.json file I downloaded from developer site.

 

[
    {
        "firstName" : "Mike",
        "lastName" : "Chepesky"      // after this ',' is missing
        "employeeNumber" : 01840192
    },
    {
        "firstName" : "Westlee",
        "lastName" : "Barichak"      // after this ',' is missing
        "employeeNumber" : 47901927
    },
    {
        "firstName" : "Jamie",
        "lastName" : "Lambier"    // after this ',' is missing
        "employeeNumber" : 51239657
    },

....................so on]

means the error occurred when parsing json. Error very stupid . I have checked it sooner.

So who uses this example json file in their applications. Please correct first, and then use.

 

Tags: BlackBerry Developers

Similar Questions

  • PowerVault MD1000: Attached directly slow to copy the data from storage.

    Hi all

    I have a powervault MD1000 attached to a PE2900 using scsi. When I write for the PV everything is ok, but when I want to read it, for example copying the data from it, he grinds the server stops and usually falls!

    can someone advice could be what the problem?


  • When the signer will sign on the doc that I want to fill the date today, and he should be able to change the date

    Hello world.

    I joined salesforce with echosign.

    I need a help, whenever signatory 2 goes to sign on the doc I want to fill the date today and the signatory 2 should be able to change the date preceding the date of signature. 

    Hello

    So firstly follow the post on the forum to create a formula in salesforce field that creates the date as a string and this merge field in an agreement echosign.

    For example, configure the following field to receive the sfdc date string:
    {{todayeditable_es_:signer1}}

    of course to call the field all you want and also assign the right if not signer signatory 1.

    You can then add a calculated field that compares the date in the field of the todayedtiable against today's date

    {{datecheck_es_:signer1:calc(if(date([today]) > now(), "today larger than today", "continue to next step"))}}

    so, for example today's date is February 12, 2015
    the date entered in the todayeditable field is
    12/02/2015
    the audit date field will say "contine" (or whatever text put you between quotation marks)
    If the date entered has been
    13/02/2015
    datecheck displays "today higher than today.

  • Simple function/procedure in the data mask

    Hello
    Y at - it a simple method to hide the data.

    I have data stored in the tables of my base. I need to create a flatfile and send these data to the other Dept. But there are some important data like credit card, first name and last name must be masked when sending outbound flat file.

    What I use dbms_crypto for this or other simple methods are there for a time hiding?
    If I use dbms_crypto and if I have a column x varchar2 (100), will I get similarly data length varchar2 (100) after masking?

    Thank you
    Manoi.

    Well, you could do something like this:

    SQL> select t.first_name
      2  ,      t.last_name
      3  ,      lpad('*', length(t.first_name), '*') masked_first_name
      4  ,      lpad('*', length(t.last_name), '*') masked_last_name
      5  from   hr.employees t
      6   where  rownum <=5;
    
    FIRST_NAME           LAST_NAME                 MASKED_FIRST_NAME         MASKED_LAST_NAME
    -------------------- ------------------------- ------------------------- -------------------------
    Ellen                Abel                      *****                     ****
    Sundar               Ande                      ******                    ****
    Mozhe                Atkinson                  *****                     ********
    David                Austin                    *****                     ******
    Hermann              Baer                      *******                   ****
    
  • My browser is running do not. I uninstall, install several times. Uninstall cookies, delete the data from the user, install in another user - no reaction. What's wrong? Help, please

    My browser is running do not. I uninstall, install several times. Uninstall cookies, delete the data from the user, install in another user - no reaction. What's wrong? Help, please

    Start Firefox in Safe Mode {web link} by holding down the < shift >
    (Mac options)
    key and then from Firefox. Is always the problem?

    Start your computer in safe mode with network. Then launch Firefox.
    Try the sites secure web. Is always the problem?

    Start the computer in Mode safe;
    Free online encyclopedia

  • I bought an iPhone 6s and want to transfer the data from my old iPhone 4S with iTunes

    I bought an iPhone 6s and want to transfer the data from my old iPhone 4S with iTunes but it says "the"iPhone"iPhone cannot be used because it requires a newer version of iTunes. Go to www.itunes.com to download the latest version of iTunes. "

    I checked and the version of itunes is the latest AID!

    DooozySue wrote:

    I checked and the version of itunes is the latest AID!

    Most likely, what you found, is that the iTunes version is the latest available for your operating system.

    The latest version of iTunes is 12.4.3.  This version requires at least OS X 10.8.5 or later version, or Windows 7 or later version.

    If your iTunes version is earlier than 12.4.3, it will probably not recognize your 6s performance iPhone iOS 9.

    If you do not have the required operating system, get first.  Then download from iTunes

    http://www.Apple.com/iTunes/download

  • Unable to delete the data from the Safari Web site...

    Hello.

    I need help with my Safari browser on my Mac.

    Im trying to remove all Web site data with the following procedure:

    Safari-> Preferences-> privacy-> Remove All Data Web site...

    His does not work. Before clicking on the button I have 108 Web sites stored cookies or other data, I click the button, and nothing happens... I'm still 108 cookies.

    I also did the following:

    . - activate the Menu developer and Cache empty and tried again... nothing

    . - used CleanMyMac v3 and it says I don't have cookies.

    . - order iCloud Sync of Safari on the computer and try again... same problem

    . - removed manually com.apple. Safari. Secure

    Any help will be great. Please let me know if you need any additional info.

    Thank you.

    Hello DZanvettor,

    Thank you for using communities of Apple Support.

    If I understand your message that nothing happens when you try to remove the Safari Web site data. I know how it is important for you to be able to remove the Safari Web site data. I recommend that you restart your Mac into safe mode and see if you can remove the data from the Web site in secure mode.

    Here are the steps to restart your Mac in safe mode:

    Safe mode (sometimes called secure boot) is a way to start up your Mac so that it performs certain checks and prevents certain software from loading automatically or opening.

    From your Mac in safe mode does the following:

    * Check your startup disk and attempts to fix problems if necessary directory
    * Loads only required kernel extensions
    * Prevents the elements start and the login items open automatically
    * Disables installed user fonts
    * Delete font caches, hiding the kernel and other files of the system cache
    * Together, these changes can help resolve or isolate issues related to your startup disk.

    Follow these steps to start in safe mode.

    1. start or restart your Mac.
    2. as soon as you hear the startup tone, hold down the SHIFT key.
    3. release the SHIFT key when you see the Apple logo appears on the screen.

    After you delete data from the Web site in safe mode restart your Mac and allow it to start up as usual. Then test the issue again.

    Best regards.

  • Hi I want to erase all the data from my current phone if I erase content and settings would be deleted all the data off my sim card? Thanks for your help

    Hi I want to erase all the data from my current phone if I erase content and settings would be deleted all the data off my sim card? Thanks for your help

    Erase the data on your phone will not erase the data on the sim card.

  • If I remove all the data from the Web site it will also remove all my passwords?

    If I remove all the data from the Web site it will also remove all my passwords?

    It will not erase your saved in the Keychain passwords, but you need to connect back to all Web sites (like this one) that require you to log in.

  • Extract the data from the ReadyNAS Duo 3 to disk?

    Hello

    I have a ReadyNAS Duo chassis crashed with two drives of 3 TB in it. Both discs seem to work very well.

    How can I do to retrieve the data from disks of theses? they were in a RAID 1 configuration, so I guess I just need to extract one of the disks. Does it matter which drive is it?

    I started to connect one of the disks to an installation of Ubuntu and I can find from the disc with respect to the available partitions, but I get no info on the file system used, only that it is flagged as RAID.

    Because I don't want ot destroy all the data I was very careful when working with the partitioning tool. So far, I've installed and looked parted, gparted, gdisk and a few others.

    Since I'm really new to Linux, I need more detailed assistance with indicators to be used to access the drive.

    Any input is highly appreciated.

    Christoffer

    Look at this: http://kb.netgear.com/app/answers/detail/a_id/29961?utm_source=community&utm_medium=announcement&utm...

  • How to read the data from a channel named in windows using labview

    Hello

    I need to read the channel named in windows data. The pipe is created by python by another application. This application post permanent data on the pipe. But I don't know how to read data using labview. is it possible to read the data from different application? If possible, how to start?

    Thanks in advance

    concerning

    RJ

    Hi Rolf,.

    It's just, because of driving is not initialized completely, pipe read returns error 42, I added 2 seconds late, then its work perfect.

    Thank you very much.

    Concerning

    RJ

  • To access the data from database to a remote computer

    Hi all

    Can someone tell me how to access data from a database, sitting on another computer? I use the Sqlite database. It works fine in my computer. But I don't know hoe to put the database in another computer (server) and access the data from there. In my program, it is essential to do this for a simultaneous use for different users. Someone please help.

    Kind regards

    Cindy.

    I found the solution... http://ConnectionStrings.com/

  • I'm not allowed to transfer the data from the laptop on an external hard drive.

    Original title: operating system Windows 7, problems with Permissions

    I use the Windows 7 operating system. Recently my system I cannot transfer all the data from my laptop to any external hard drive. The Popup says that you don't have any administrative permissions... I am a single user and a newspaper with my Admin password but some how it continues to be. Help, please.

    You may need to take possession of the records on your external drive - see here:
    http://social.answers.Microsoft.com/forums/en-us/w7network/thread/24bdf172-2DBC-43b8-995d-a99b6a81413c/
    Alternatively, you can reformat the external hard drive.
  • How to join two tables to retrieve the data from the columns in table two. Tables have primary and foreign key relationships

    Hello

    I want to join the two tables to retrieve the data from the columns of the two table passing parameters to the join query. Tables have primary and foreign key relationships

    Details of the table

    Alert-1 - AlertCode (FK), AlerID (PK)

    2 AlertCode-AlertDefinition-(PK)

    Help, please


    ----------

    Hi Vincent,.

    I think that you have not worked on adf 12.1.3.  In adf 12.1.3 you don't have to explicitly create the association. When you create the EO to your table, Association xxxxFkAssoc, will be created by ADF12.1.3 for you automatically. Please try this and do not answer anything... You can also follow the links below. I solved the problem by using the following link

    Oracle ADF Guide step by step - Oracle ADF tutorial: creating a relationship of the master / detail using Oracle ADF

    ---

  • Generic procedure to load the data from the source to the table target

    Hi all

    I want to create a generic procedure to load data of X number of the source table to X number of the target table.

    such as:

    Source1-> Target1

    Source2-> Target2

    -> Target3 Source3

    Each target table has the same structure as the source table.

    The indexes are same as well. Constraint are not predefined in the source or target tables.there is no involved in loading the data from the business logic.

    It would simply add.

    This procedure will be scheduled during off hours and probably only once in a month.

    I created a procedure that does this, and not like:

    (1) make a contribution to the procedure as Source and target table.

    (2) find the index in the target table.

    (3) get the metadata of the target table indexes and pick up.

    (4) delete the index above.

    (5) load the data from the source to the target (Append).

    (6) Re-create the indexes on the target table by using the collection of meta data.

    (7) delete the records in the source table.

    sample proc as: (logging of errors is missing)

    CREATE or REPLACE PROCEDURE PP_LOAD_SOURCE_TARGET (p_source_table IN VARCHAR2,

    p_target_table IN VARCHAR2)

    IS

    V_varchar_tbl. ARRAY TYPE IS VARCHAR2 (32);

    l_varchar_tbl v_varchar_tbl;

    TYPE v_clob_tbl_ind IS TABLE OF VARCHAR2 (32767) INDEX OF PLS_INTEGER;

    l_clob_tbl_ind v_clob_tbl_ind;

    g_owner CONSTANT VARCHAR2 (10): = 'STG '.

    CONSTANT VARCHAR2 G_OBJECT (6): = 'INDEX ';

    BEGIN

    SELECT DISTINCT INDEX_NAME BULK COLLECT

    IN l_varchar_tbl

    OF ALL_INDEXES

    WHERE table_name = p_target_table

    AND the OWNER = g_owner;

    FOR k IN l_varchar_tbl. FIRST... l_varchar_tbl. LAST LOOP

    SELECT DBMS_METADATA. GET_DDL (g_object,

    l_varchar_tbl (k),

    g_owner)

    IN l_clob_tbl_ind (k)

    FROM DUAL;

    END LOOP;

    BECAUSE me IN l_varchar_tbl. FIRST... l_varchar_tbl. LAST LOOP

    RUN IMMEDIATELY "DROP INDEX ' |" l_varchar_tbl (i);

    DBMS_OUTPUT. PUT_LINE (' INDEXED DROPED AS :'|| l_varchar_tbl (i));

    END LOOP;

    RUN IMMEDIATELY ' INSERT / * + APPEND * / INTO ' | p_target_table |

    ' SELECT * FROM ' | '. p_source_table;

    COMMIT;

    FOR s IN l_clob_tbl_ind. FIRST... l_clob_tbl_ind LAST LOOP.

    EXECUTE IMMEDIATE l_clob_tbl_ind (s);

    END LOOP;

    RUN IMMEDIATELY 'TRUNCATE TABLE ' | p_source_table;

    END PP_LOAD_SOURCE_TARGET;

    I want to know:

    1 has anyone put up a similar solution if yes what kind of challenges have to face.

    2. it is a good approach.

    3. How can I minimize the failure of the data load.

    Why not just

    create table to check-in as

    Select "SOURCE1" source, targets "TARGET1", 'Y' union flag double all the

    Select "SOURCE2', 'TARGET2', 'Y' in all the double union

    Select "SOURCE3', 'Target3', 'Y' in all the double union

    Select "SOURCE4', 'TARGET4', 'Y' in all the double union

    Select 'Source.5', 'TARGET5', 'Y' in double

    SOURCE TARGET FLAG
    SOURCE1 TARGET1 THERE
    SOURCE2 TARGET2 THERE
    SOURCE3 TARGET3 THERE
    SOURCE4 TARGET4 THERE
    SOURCE.5 TARGET5 THERE

    declare

    the_command varchar2 (1000);

    Start

    for r in (select source, target of the archiving of the pavilion where = 'Y')

    loop

    the_command: = "insert / * + append * / into ' |" r.Target | ' Select * from ' | '. r.source;

    dbms_output.put_line (the_command);

    -execution immediate the_command;

    the_command: = 'truncate table ' | r.source | "drop storage."

    dbms_output.put_line (the_command);

    -execution immediate the_command;

    dbms_output.put_line(r.source ||) 'table transformed');

    end loop;

    end;

    Insert / * + append * / into select destination1 * source1

    truncate table SOURCE1 drop storage

    Treated SOURCE1 table

    Insert / * + append * / to select TARGET2 * in SOURCE2

    truncate table SOURCE2 drop storage

    Treated SOURCE2 table

    Insert / * + append * / into select target3 * of SOURCE3

    truncate table SOURCE3 drop storage

    Treated SOURCE3 table

    Insert / * + append * / into TARGET4 select * from SOURCE4

    truncate table SOURCE4 drop storage

    Table treated SOURCE4

    Insert / * + append * / into TARGET5 select * from source.5

    truncate table source.5 drop storage

    Treated source.5 table

    Concerning

    Etbin

Maybe you are looking for

  • Where are the sides 'star' on the latest version of the music for the iPhone?

    Previously, I could see, add and change the collation 'star' of songs on my iPhone.  I do not find this option.  This a large part of how I organize and track my music collection, which is massive and therefore can be very difficult to manage.  It wa

  • Blocked access

    I get this message whenever I want to download some files I feel safe: "Windows found that this file is potentially harmful.  To protect your computer, Windows has blocked access to this file. I was able to unlock some files using properties > unbloc

  • CSCux34781 - assessment of the acs5 for Java_December_2015

    Hello What is the status on this bug? It is marked with the 'Fixed' status, but it is not any information on how to implement a fix.Unlike the status indicator, the fixed versions "known" has the counter to 0.The description says that "all the patche

  • BlackBerry Smartphones BBM feature request: blocking messages broadcast

    I searched this forum and (surprisingly) not found references to what is perhaps the most annoying 'feature' that LINE has implemented since I've owned a Bay. In providing the function of dissemination in the new versions of Messenger, my berry is no

  • BSOD problems with a computer of windows 8

    Hello. I've had my computer for over a year now, and since about a week after I got it I had several problems with it. Initially, I had problems with usb devices works sometimes not. In this case I have to restart several times hoping to rework them.