Display QList ListItemData < QVariantMap > with < QVariantMap > 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

Tags: BlackBerry Developers

Similar Questions

  • Windows Media Player displays only one album with the unknown artist.

    Original title: strange going ons

    When I go to my music using windows Explorer, it shows a folder named unknown artists with 7 subfolders.

    When I bring the windows media player, it displays only an album with an unknown artist.

    When I open one of these subfolders, writing the name of the artist, but all the tracks have been listed as track 1, track 2, track... in the library, that I went to this artist's album. He entered all the information correctly. When I clicked open the location of the file that shows the location of the albums as one of the subfolders under unknow artist and all tracks as track 1...

    so, how did we can list everything correctly in the library but point to incorrect information?

    Hello

    What are the file format of the files shown in the subfolders of the library?

    Follow these methods.

    Method 1: I suggest you follow these steps and check.

    You can try to clear the database of Windows Media Player.

    To do this, follow these steps:

    Step 1

    a. exit Windows Media Player.

    b. for Windows Vista: click Start, click run, type %LOCALAPPDATA%\Microsoft\Media Player , and then click OK.

    c. Select all files in the folder, and then click delete on the file menu.

    Note you don't have to remove the folders that are in this folder.

    d. restart Windows Media Player.

    Note Windows Media Player automatically rebuilds the database.

    Step 2

     If this does not resolve the problem, disable the Windows Media Player database cache files. To do this, follow these steps:

    a. exit Windows Media Player.

    b. If you run Windows 7, click Start, click Run, type % LOCALAPPDATA%\Microsoft and then click OK.

    c. Select the folder Media Playerand then click delete on the file menu.

    d. restart Windows Media Player.

    Note Windows Media Player automatically rebuilds the database.

    Also note before performing the steps above, I suggest to save the songs and try the steps above.

    Method 2:

    If the steps above do not resolve the problem, you can try to disable Windows Media player and then enable the feature that is as good as the uninstall and put it back. Follow the steps below to do the same.

    To enable or disable the Window Media Player, follow these steps:

    a. click the Start button, select Control Panel, click programsand then click Windows turn on or off features. If you are prompted for an administrator password or a confirmation, type the password or provide confirmation.

    b. develop media features , uncheck the box next to the Media Player functionality to remove Media Player. Click OK and restart the computer.

    c. turn on the player again by selecting the check box next to the feature of Media Player.

    Access the link below for more information on the steps above to turn off or on the features of Windows 7.

    http://Windows.Microsoft.com/en-us/Windows-Vista/turn-Windows-features-on-or-off

    See also:

    The Windows Media Player library: frequently asked questions

    http://Windows.Microsoft.com/en-us/Windows-Vista/Windows-Media-Player-library-frequently-asked-questions

  • Displaying an error message with a link to the error field

    By default, validation of the ADF has usually shows an alert with an error message and a link to the field of the error.

    I have some custom validations where I finally to display the error message with this:

    public static void MessageError (String messageText) {}

    String messageText = "" No. is han sown estos datos '; "

    FacesMessage fm = new FacesMessage (messageText);

    /**

    * set the type of the message.

    * Valid types: error, fatal, information, warning

    */

    fm.setSeverity (FacesMessage.SEVERITY_ERROR);

    FacesContext context = FacesContext.getCurrentInstance ();

    context.addMessage (null, fm);

    }

    My client application displaying a link to the field in error in this kind of error alerts as do the standard deviations.

    Is it possible to achieve this?

    Try setting the first parameter to the addMessage (which has the value null in your case) on the id of the component whose validation failed. That's what part.

    Timo

  • Status display of an element with validation of Checkbox

    Hi friends,

    I had a problem... I want to display an element in a form, we assume that it will be a text box based on the value of the checkbox in a group (LOV) checbox.

    Let me this brief... I m having a LOV with search values, improvement, development and test...


    All displaying the box point with this LOV... It's showing as: (here {case}: picture check box)

    {Case} Search
    {Case} Development
    {Case} Development
    {Case} Test

    So when I click on a box with a label, a text box should display next to her so that I can give some value in this text box, which in turn stores the value in the database in the form submiiting. So if I select more than one box, many text boxes will appear then these selected CheckBox LOV.

    Any useful response is welcome.

    If someone who reads this not clear let me know so that I will also gain experience how to post properly the thread next time.

    Thank you
    Stéphane.

    Hi again!

    Your problem is that the interface can only see the hidde or something after a shipment. So clicking on a box will not display anything before submitting the page. At the next clean. Sorry I forgot to declare v_stmt and v_ret. v_stmt is a variable VARCHAR2 (4000) that contains a dynamically generated PL/SQL - Statement.The variable v_ret is the returnvalue from the PL/SQL block. v_ret can have two values. or null. The period means that the ckeckbox has been checking NULL means that the box has not been checked.

    I hope that helps a little more.

    concerning

  • How to display a positive value with a thinner sign

    I want to display a positive value with a thinner sign and a negative value with a less fine sign. How can I do? Is there any character in the custom format for this? I don't want to convert number to text and use the case statement because I need to two decimal and thousands separator.

    OK, try this...

    You will need to do a "UNION ALL" of three queries, one for positive values, one for the values zero and one for negative values.

    In the query "negative", follow these steps:

    (1) add a filter on the measure of value 'less than 0.
    (This will ensure that all values are negative).

    (2) in the tab Format data, select "Custom" and type #, # 0.00 -
    (This will add the end negative sign.)

    (3) in the tab change the formula, add the function absolute value ABS (able to insert here)
    (This will get rid of the default signing negative.)

    For the query "positive values", change the above as follows:

    (1) change the filter to "0".
    (2) in the format of data, change the custom format #, # 0.00 +.
    Step 3 is unnecessary since all values are positive.

    For the query "values null ', just add a filter 'equal to zero.'

  • Why some images are displayed as small rectangles with numbers?

    When I visit some sites, some of the images make under small rectangles with letters and numbers on the inside. This issue seems to be with Firefox (see motogp.com_FireFox.jpg, attached), rather than the site because the site displays properly when I get another browser, such as SeaMonkey (see motogp.com_SeaMonkey.jpg,) attached.

    The website, motogp.com is one I visit frequently; It happens on this site. See 2 pictures attached for an example of this problem.

    The box identifies a character not in the police who are using Firefox. This happens usually when a site has changed use images for its icons to use characters in a custom font, you need to download. There are three common reasons for the glitch:

    (1) uncheck the box 'Allow pages to choose their own fonts' here:

    "3-bar" menu button (or tools) > Options > content > button "Advanced".

    If the pages are not allowed to specify their own fonts, Firefox uses the specified here, police who normally does not have the required pictures.

    (2) disabling fonts download. To check that:

    (A) in a new tab, type or paste Subject: config in the address bar and press ENTER. Click on the button promising to be careful.

    (B) in the search above the list box, type or paste gfx and make a pause so that the list is filtered

    (C) If gfx.downloadable_fonts.enabled preference is bold and user, set false, double-click it to restore the default value true

    (3) extension of block the download. NoScript has a feature to block the downloadable fonts, for example.

  • Facebook displays only a list with no graphics.

    For about 2 weeks now, Facebook has come in the form of list only in Firefox. In Safari, it's normal. I can click on a link and get there, but nothing is displayed on the homepage except text. I am on a Mac with the latest update of Firefox installed.

    I wonder how you got the mobile site (m.facebook.com). If you manually go to www.facebook.com you get automatically redirected to the mobile site?

  • Can I use a LED Cinema Display of pre-2009 with a new MacBook Pro retina?

    Hello

    I am currently using a pre-2009 LED Cinema Display with a MacBook Air from mid-2011.

    Now, I want to replace my old MacBook Air with a brand new MacBook Pro 13 "retina.

    This combination works always and, above all, the Cinema Display Monitor will be able to manage the resolution of the retina?

    I have never seen anything in the resolution of the retina on the screen of cinema in 7 years, so I wonder if he can really handle.

    Thanks for any help.

    The Cinema Display isn't a Retina display, so it will not show HiDPI resolutions. But it will work fine with your new machine.

  • Do not display the SVG objects with the effect of filter < feSpecularLighting >

    When I open a file Scalable Vector Graphics (.svg) in Firefox, all objects with filters that contain the < feSpecularLighting > filter primitive, are not displayed at all, and in rare cases, even cause Firefox crashes.

    For example:

    It must be rendered like this:

    In order to get the SVG file to render as PNG, you must edit kernelUnitLength of 0.01 to about 1.0 (or delete). Don't know if something might have changed in the way Firefox handles this attribute to cause such a radical difference.

    I should test in a clean profile to see if I get the same result...

    Edit: Same result in a clean profile, i.e. without extensions or changes to the default factory settings.

  • Dual HDMI display does not work with Toshiba still WT8

    Hi all

    I noticed that the duplication of the screens via HDMI is not possible with the Toshiba still WT8. There seems to be a recognized problem, however, my question is:

    Is it possible to manually operate?
    When released the drivers/fix at Toshiba?

    Thank you.

    The tablets micro HDMI to HDMI Cable port with Type D connector can connect.

    To select the display mode, you must go to:
    Control Panel (this can be found under System Windows Apps view)-> appearance and personalization-> display-> Change display settings-> avancΘs-> list all Modes

    Now, select one of the modes in the list all Modes

  • Please help - FF displays a bow square with characters in it, not a policy.

    I read some responses to this topic and I made adjustments that they talked about a none of them worked.

    I have a new installation of 3.6.12 on a new machine.
    On Facebook & Twitter and many other sites and any page translator and or applications, I find myself with this square box with a hexadecimal number (I see called) I made the adjustments in "allow sites to use there fonts" and some other ideas and each time I restarted FF and even the machine several times after adjustment.

    I use translator pages often and none of them will not display a correct characters.

    Please, I need to fix this!

    Thank you

    Make sure that you have installed East Asian language support and support for complex scripts:

  • Display problems using Firefox with Windows 7, 64-bit

    Hi support them

    I have a new desktop computer running Windows 7, 64 bit.
    When I use Firefox version 3.6.8 to view my Web site, it displays everything out of alignment.
    If I use IE 8.0 it shows very well.
    If I use my laptop which is running Win XP site displays fine with IE 8.0 and Firefox.
    So I guess it may be a problem with Win 7, 64 bit and Firefox work well together.
    Is there a ready solution to help solve this problem or I have to wait until Firefox came out in a 64-bit version?

    Reset the page zoom on Web sites that have bad air: "view > Zoom > Reset" (Ctrl + 0 (zero))

    See http://kb.mozillazine.org/Zoom_text_of_web_pages

    See also the font size and zoom - increase the size of web pages and font size and zoom - increase the size of web pages and change use the sites of fonts and colors

    If you increased the minimum font size then try a lower setting (default is none) as too high can cause problems that you described.

    Tools > Options > Content : Fonts & Colors: Advanced > Minimum Font Size
    Tools > Options > Content : Fonts & Colors: Advanced > "Allow pages to choose their own fonts, instead of my selections above"
    
  • IE9 does not display graphics at all with two display running drivers.

    Hi all. Thank you for taking the time to read my first post.
    I just picked up my new A660 reception - 1 H 7. For some reason, Internet explorer 9 appears not at all no graphics while two display drivers are running. I have intel HD Graphics and nVidia 310M graphics installed in Device Manager and only when I turn off the nVidia 310 m it doesn't then display graphics in IE9. If I disable the Intel HD graphics card, the entire screen goes completely and I have to force a reboot hard to recover.
    Could someone please explain to me why I have two display drivers? I guess the nVidia card is the most powerful on both but can't make it work independently of the Intel one, if there is a fix for the display problem in IE9.

    Pause to breathe!

    Thank you everso much and I look forward to contribute to this forum myself by helping someone soon.

    Hello

    What is your laptop pre-installed with Toshiba recovery image original you got with your laptop (WIN7 64 BIT HOME PREMIUM)?
    I put t understand how you can have listed two graphics cards when your laptop specification says your laptop's graphics card from NVIDIA to inside.

  • Display of shimmering red with Toshiba Portege S100

    Hello
    After doing a few partition with partition magic, I returned to find that she had been unable to boot into windows and had a red screen now.
    Restart in windows, I could get however now parts of the screen has a red screen (usually in black or blue screen bits).

    I tired of restoration of the system, uninstalling and reinstalling display drivers and also update the BIOS. I also tried different distributions of CD live linux, but they also have a red tint and a few shimmering.

    I do not have an external monitor to connect my laptop up but I suspect it's more a problem of hard disk corrupted than anything else. Does anyone have ideas outside of an erasure full + reinstalling windows?

    Hello

    so, if you think that the hard drive then why Don t Exchange it and give it a try? I think that perhaps something of your graphics as vga or lcd chip subsystem could be faulty, but that's just my opinion. :)

    If you are really trying to change the hard drive and you got no success, then I suggest you to contact a local servicepartner for a hardwarecheckup or maybe a repair. You are still in warranty?

    Welcome them

  • 27 inch Cinema Display will work ok with end of 2013 imac

    Hello

    I have the chance to get a Cinema Display 27 inches for a good price. Will it work ok with my iMac 27 inch end of 2013? If so, is there a difference between this model and the current model of PQ crush?

    Thank you

    Hi, Richard.

    Please visit Apple support communities.

    I understand that you want to use a movie with your iMac screen compatibility.  Without knowing the technical data of the movie screen and looking at your specifications, this view should work with your end of 2013 27-inch iMac.  Your iMac has two Thunderbolt ports that can support the Thunderbolt screens and output Mini DisplayPort.  Below, you will find more information on the specifications of your system and the use of several screens with your iMac.

    iMac (27 inch, end 2013) - technical specifications

    OS X El Capitan: connect multiple monitors to your Mac

    See you soon

Maybe you are looking for