very simple custom DataModel derived from bb::cascades:DataModel will not display data in ListView

Hello

A model of custom data in C++, I did nothing appears in a ListView

It seems that the link

listView.dataModel = _dataModel

on QML side don't ask the DataModel data. I'm not really sure what I'm doing wrong.

PS. Place the CustomDataModel in QML as an attachedObject and insert data it works, but I have a specific need to keep the DataModel in C++.

Below the example of code reduced to the simplest case which cause me problem:

//customdatamodel.h

#include 
#include 
#include 

class CustomDataModel : public bb::cascades::DataModel
{
Q_OBJECT
  public:
    CustomDataModel(QObject * parent=0) : bb::cascades::DataModel(parent)
    {
    }
    virtual void ~CustomDataModel()
    {
    } 

    virtual int CustomDataModel::childCount(const QVariantList& indexPath)
    {   //just one level deep
        return 0;
    }

    virtual bool CustomDataModel::hasChildren(const QVariantList& indexPath)
    {
        return childCount(indexPath) > 0;
    }

    virtual QVariant CustomDataModel::data(const QVariantList& indexPath)
    {
        if (indexPath.count() == 1)
        {
            return m_values[indexPath[0].toInt()];
        }
        return QVariant();
    }

    void CustomDataModel::insert(const QVariantMap &item)
    {
         m_values.append(item);
         emit itemAdded(QVariantList() << m_values.count()-1);
    }

    private:
      QVariantList m_values;
}

//application.cpp

ApplicationUI::ApplicationUI(bb::cascades::Application *app)
: QObject(app)
{
    qmlRegisterType("app.datamodels", 1,0, "CustomDataModel");
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);

    CustomDataModel *dataModel = new CustomDataModel(this);

    QVariantMap map;
    map["field"] = "value1";
    dataModel->insert(map);

    map = QVariantMap();
        map["field"] = "value2";
    dataModel->insert(map);

    map = QVariantMap();
    map["field"] = "value3";
    dataModel->insert(map);

    qml->setContextProperty("_dataModel", dataModel);

    AbstractPane *root = qml->createRootObject();
    app->setScene(root);
}

//main.qml

    Page {
        Container {
            layout: DockLayout {
            }

            ListView {
                id:listView
                dataModel: _dataModel

                function itemType(data, indexPath)
                {
                    if (indexPath.length == 1)
                    {
                        return "item";
                    }
                }

                listItemComponents: [

                    ListItemComponent {
                        type: "item"
                        StandardListItem {
                            title: ListItemData.field
                        }
                    }
                ]
            }
        }
    }

Hello
You always return a zero childCount, so he thinks that the template is empty.

Tags: BlackBerry Developers

Similar Questions

  • My Muse site will not display the customized html images that work in chrome?

    My Muse site will not display the customized html images that work in chrome? Here's my url www.simplesites.com.au.

    Works fine here on Linux.

    Note that the uploads has 'ads' in name and come from simplesites.net.au, so be sure that content blockers not get triggered.

  • I downloaded the latest DNG from Adobe, but it will not read my Canon RAW files. I am running windows 10

    I downloaded the latest DNG from Adobe, but it will not read my Canon RAW files. After downloading, I loaded the program and then go to select the folder. When I go to records RAW files aren't there. I used DNG in the past with no problems but I have a new PC and running windows 10 and he would not consider my files RAW Canon cameras for some reason any. What am I doing wrong or it is not compatible with windows 10.

    Thanks, I use PLR, but I wanted to convert using DNG. It is all sorted now

  • ListView will not display datamodel set of c ++

    I have a listview that retrieves a file from a web service json and it analyzes in a datamodel (tried GroupDataModel and QListDataModel). Thanks to some discussions that I found here, I managed to get the data in the data model and attach properly to the listview. which I checked through debugging.

    However; When I return to QML, I'm not able to get the data to display.

    My loots listview like that at the moment, but it's really just a lighter version of what I want, since I'm trying to make it work:

    ListView {
                                objectName: "list"
                                listItemComponents: [
                                    ListItemComponent {
                                        type: "item"
                                        Container {
                                            id: root
                                            WebImageView {
                                                url: ListItemData.image
                                            }
                                            Label {
                                                text: ListItemData.title
                                            }
                                        }
                                    }
                                ]
                            }
    

    Regarding my code, c ++, I use the Twitter example found here as my base:

    http://supportforums.BlackBerry.com/T5/Cascades-development/method-for-making-an-HTTP-style-request-...

    For reference, if I try to use QListDataModel, my cards will eventually look like this:

     QMap(("Description", QVariant(QString, "Description here") ) ( "image" ,  QVariant(QString, "https://image.com/image.jpg") ) ( "title" ,  QVariant(QString, "title") ) )
    

    As I said, I see the datamodel get associated with my list by list-> setDataModel (model); but it does not display anything. I'm sure it's something on the side QML that I'm hurting, but hopefully someone here can help.

    So, I realized my problem while working on another part of the application.

    Unlike the example of Twitter I've provided, I wasn't using a global variable for * root. I believe that when I started with this example, that part was giving me problems, so I used local variables. For this reason, my application created the root object in the initialization and the method of "GetTimeline".

    Once I did fixed it is global, the list filled.

    Thanks for your help on this everyone.

  • "Error message: Verifing DMI pool Data data ', 'Boot from CD' and Vista will not start.

    Vista will not start. Yesterday I had a remote assist of a tech trade SPS who took several Java updates and installed the recommended Java version. Until I left work the day I closed my computer so that he could install the updates from Microsoft. After the updates were finished I he turned and left for the day. When I arrived this morning, I had was a black screen and 2 lines of text following: 'Verifing DMI pool data' and 'Boot from CD' and a cursor flashing beneath them. I downloaded and executed a Western Digital utility that showed no problems with the hard drive, put in on the installation disc repair service is no error. I did a system restore to a point since yesterday morning, and Vista still does not start. Any ideas or suggestions?

    Hi JohnHorky,

    Step 1:

    First check and make sure that all physical connections on the computer are correct.

    Step 2:

    Alternatively, you can try to run a Checkdisk and check.

    a. Insert the installation disc.

    b. restart your computer.

    c. click on the Start button, click the arrow next to the button lock and then click on restart. If you are prompted, press any key to start Windows from the installation disc.

    d. choose your language settings, and then click Next.

    e. in the System Recovery Options menu, click command prompt

    f. at a command prompt, type the following command and press ENTER

    Chkdsk /f /r X: (drive letter)

    Note: When you run the checkdisk, there are risks of data loss you can take a backup before starting the checkdisk.

    g. press y when you are prompted to check the drive the next time the system restarts.

    h. close all applications and restart the computer.

    Note: When you run the disk check, there are chances of losing data if you can take a backup before starting the checkdisk.

    Step 3:

    Check if the automatic hard drive in the BIOS (Basic Input/output System) is enabled and save settings and check if it works. If it doesn't, contact the manufacturer of the system for more support options.

    I also suggest that you install the latest update of the basic system of input/output (BIOS) on the computer by contacting the manufacturer of the computer and check if it helps.

    Important: Change to the BIOS/complementary metal oxide semiconductor (CMOS) settings can cause serious problems that may prevent your computer from starting properly. Microsoft cannot guarantee that problems resulting from the configuration of the BIOS/CMOS settings can be solved. Changes to settings are at your own risk.

    Hope this information is useful.

  • The Smartphones from blackBerry Desktop software will not connect to 9700 Win 7

    Recently, I lost my 9800 "BOLD" and had to go back to my old 9700.  When you try to resynchronize the 9700 for the desktop software, it started the process but then stopped.  Now the software connects to the device even if the device shows connected to the desktop computer.  In addition to the software crashes and cannot be closed.  I tried to uninstall and reinstall the desktop software but no improvement.

    Any ideas.

    Thank you

    Peter

    Interesting... the only time wherever I got a message like that is when I am attached to my PC and using the AppWorld on the web from my PC browser... a plugin is installed on the PC so that it works. I never recall a message as you describe directly from the desktop software.

    There is no need to use the older Desktop software... in fact, under Win7, it is even probably not supported. So, now I suggest the following steps (reboots insert a lot of restarting your PC... not only restarts, but at full power down). In addition, it is recommended that you are connected to the PC on an account with full administrator rights. In addition, under Vista/Win7, use the option "Run As Administrator" for everything.

    In addition, it was also reported that when your user profile on windows (type "echo %UserProfile%" in command prompt) contains spaces, then the installer will not work. To resolve this issue, log off from your Windows account and sign in using the local administrator account (or any other name of account without spaces) and install office (for all users).

    (1) delete your package to update device OS of your PC (Add/Remove Programs)

    (2) properly uninstall the RIM desktop software:

    • KB02206 How to perform a clean uninstall of BlackBerry Desktop Software
    • Some noted that there are several registry keys to remove talk in this KB... don't forget to get your all associated with RIM registry database
    • Others have reported the use of a registry cleaning tool to be also useful
    • Still others have reported the use of your original PIM (Outlook, NOTES, etc.) Installation CD, run the "repair" to be helpful in some situations process

    (3) obtain a new download of the RIM Desktop software:

    (4) to download a new copy of your package to your carrier OS device (on your PC):

    (5) install the software on your PC Desktop

    Installation of 6) (also on your PC), device OS package

    (7) start the configuration Organizer:

    • KB17022 How to configure applications to Organizer for synchronization using BlackBerry Desktop Manager
    • KB23681 How to configure settings to synchronize Organizer data using BlackBerry Desktop Software 6.0

    If all goes well, who's going to make things again.

    Good luck and let us know!

  • 33.1 FireFox will not display the PDF file from the website of the Bank after 33.1

    I asked this question in a non-support ticket so I want to give more details here. I tried to uninstall Adobe reader and reinstall and it did not help. It worked before with all the exact same addins I had before. I called the Bank and asked if they had any problems and they say no. I can go to the Firefox PDF display for this file and click Download the PDF file, then double-click it in Windows Explorer and Adobe reader appears and displays the file very well. Don't mind what to do at the moment. What happens is the Bank to load the file then Adobe reader opens with a white screen and a small circle going round and round, like a video trying to play, and it is just there for always. I never see the content of the file. In any case I hope that your have a good of a day as I am and I know that it improves. Thanks Firefox programmers for such a wonderful program.

    Update: while I was writing this I thought to go in Firefox options, then Applications, and wouldn't you know, a PDF document has been set to "Preview in Firefox. I changed that to Adobe reader and now it works fine. Suppose that there is something wrong with the code in Firefox. So I'm happy now. Hope this helps someone.

    Yes, the built-in PDF Viewer is a work in progress. Glad you found a workaround, or go to your favorite configuration, depending on how you look.

  • HP deskjet 3050 j610: when I try to scan from my printer it will not connect

    When I try to scan from my printer I get a message "Cannot find HP deskjet 3050 j610. But I can print from it and get data as ink tank printer. It started abruptly today. It worked OK until a few days ago.  The printer is connected by a USB cable. I tried the driver update and 'repair' menus via HP scanning problems without success.  If I press scan on the printer button it says "scan error. try to scan from computer', but that's what I usually do using the calculation icon in the menu START.

    I solved the problem. The basic steps were (1) using the HP links to update my driver printer and research to find errors in the scanning program. (2) restart my computer and printer. After the first part, I didn't see any listed results. Normally I would have restarted the printer and the computer, but is afraid of losing my sites and the investigation, so I kept looking for the various comments.  I found a reference to this site in one of the post near mine for a #7520 device but cannot return immediately to give the author of the post. I think I sent him a response.

    http://support.hp.com/us-en/document/c00040499.

    This site gives lots of tips for different situations and devices. I followed the advice that it applied to my computer and printer who ended with step 2 (I use a USB connection) and the scanner was working again.

  • Cascades Cookbook will not build: no rule for target ' mk/cs - base.mk'.

    I downloaded Cascades Cookbook (qml version Gold) on the web at:

    http://developer.BlackBerry.com/Cascades/files/release/samples/10_0/cascadescookbookqml.zip

    I imported (file; Import; Existing projects in the workspace) in my Momentics IDE & get the following error when I build:

    No rule for target ' mk/cs - base.mk'.

    Any ideas what is the problem?

    I'm trying to figure if I could use something before 'gold' SDK but don't know how to check (Momentics says help I use 10.0.6 but this seems odd, given that the gold shows that 10.0.09...must be different but similar looking for versioning).  Is there a way to check if you have the latest updates?  Tried checking for updates under the Help menu, but this does not seem right.  You have to download another 3/4 GB of SDK, whenever there is an update?

    There is the "Update Native SDK" button on the toolbar in recent versions of Momentics but you will have to update to the latest downloadable first of all.

    Watch version 10.0.9 mine in about-> help.

    The latest version of samples can be downloaded on github:

    https://github.com/BlackBerry/Cascades-samples/tree/master/cascadescookbookqml

  • Smartphones from blackBerry Desktop Manager will not show that I am connected

    My "BOLD" will connect to my Vista computer via a USB port. I can copy files if I do it myself. Blackberry Device Manager shows that I am connected to my computer. The Desktop Manager program does not show that I am connected. It says I am disconnected. I am the administrator of the computer. I loaded the program using the option "Run as Administrator" enabled. It's very frustrating! Please help me.

    Thank you

    I got it! I had installed the program Microsoft parental control on my computer and things seem to start down. I uninstalled the program, and everything seems to be working again!

  • Message from blackBerry Smartphones that will not disappear every 20 minutes

    Hi I get of "[email protected]" he says don't not to open the attachment and it wil be processed by the server. This changes every 20 to 30 minutes and lasts for weeks. My e-mail works fine, but it's very annoying. Any help!

    Hello AlanW,

    While, I stumbled on this thread today that describes the same problem as you:

    http://supportforums.BlackBerry.com/T5/General-BlackBerry-smartphone/weird-messages/TD-p/505349

    try to follow that proposed contributors to do this, it might be useful

  • Lightroom 6 CD ejects from the IMAC and will not install

    Just bought my first LR (at amazon) but my IMAC (mid-2010) ejects the CD. Updated operating system up-to-date v10.8 and other requirements met in accordance with the back of the packaging. Does not cloud, or wireless, ethernet.  Help is appreciated. ...

    Hi annal,

    Please install Lightroom 6 from the following link: https://helpx.adobe.com/lightroom/kb/lightroom-downloads.html

    Kind regards

    Tanuj

  • From 50.0, Firefox will not load the tabs. How can I treat?

    Recently (very probably coinciding with the 50.0 update), Firefox suddenly stopped loading tabs. All the pages get stuck on 'connection '.... "as well as system as topic tabs: support and about: config. Google.com and other Web sites and locations internal intranet do not load.

    The first tab that opens at the start of Firefox will sit on a white page indefinitely, not to load the page speed dial 'shortcut '. Not even the tabs system such as topic: support load. If a second tab is open, and the first tab is closed, then the tabs system become available, but websites will always be blocked to 'connection '.... »

    This troubling behavior began to appear in dozens of jobs in our Organization. On each of them, except one (so far), we were able to resolve by obtaining: support to load using the method described above and refreshing of Firefox, which leads me to believe there is some sort of problem with the profile.

    On a desktop, Firefox seems to work after a refresh, but after an instance of Firefox is closed and a new opening, the new question asserts itself. When you open Firefox under a new user profile, it works once before breaking. On this particular station, I tried uninstall Firefox and reinsert several times without success, as well as facility nightly, which presents the same exact issues as the regular version. I'm stumped on how to solve this problem for the end user. I even tried to run CCleaner.

    Any ideas?

    Hi HaggenIT, can you please try the following and see if it works: enter Subject: config in the address bar of firefox (confirmed the message information where it appears) & search for the preference named browser.tabs.remote.autostart.2. Double-click it and change its value to false.

  • How to create custom underscore and make a style that will not change the style of text when it is applied?

    Hi, I just want to know how can I create custom underscore and make a style, so that when I apply it to the text it right to point out that the article selected

    As long as no other character style is applied, you can create and apply a character style that is completely empty except for underscores. That will add an underline without affecting the text in any other way. If a different character style is already you must either add an underscore to this style definition (which will add an underline to all text formatted with this style) or make a copy of the style and add the underline, and then apply the new style.

  • There is a section of 3 inches from the window which will not recognize the mouse. It will not let you click on the icons or the screen somehow in this section under the address bar. It is only in firefox when it comes to a problem

    There is a section of 3-inch window that do not respond or recognize the mouse. It not let you click on the icons or the screen somehow. It is the only program that we are facing this problem with.

    Start Firefox in Firefox to solve the issues in Safe Mode to check if one of the extensions or if hardware acceleration is the cause of the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > appearance/themes).

Maybe you are looking for

  • Melted white MacBook Pro screen

    Hello I'm having a problem with my MacBook Pro Retina 2015, the screen freezes and fades to white! IV ' e only had it since December 2015! has anyone seen this problem before? If I have him take it back to Apple they will repair it or offer me a new?

  • Selecting text in Quickoffice

    I can't find a way to select chunks of text in the program of Quickoffice Quickword. Anyone know if it is still possible, and if so, what is the trick? Thanks in advance for your help...

  • The M-series multiplexer sequencer allows to sequence external multiplexers?

    Hello community OR. I have been using a set of IA-32 M-series cards to scan the independent streams of data to the 32 kech. / s.  The source of the signal is a series of very low voltage signals current 256 (action potentials in the brain of a rat in

  • Missing screws after installation of the Runtime

    Hello I had installed Labview 2015 and created all my screws, then after that it worked, I uninstalled all with labview and installed only the Runtime. But now I miss some subvis. "For example NI_AALBase.lvlibtd deviation and Variance. It is not any

  • 7 d Mark II with a teleconverter 1.4 x - WOO HOO!

    So, just a few weeks ago, I found myself in an interesting position - let me explain. I had a 60 d that I loved for the past 3 years.  But... I have a 100-400 f4 - 5.6 L that I also like.  BUT I'm also a 1.4 x teleconverter I sometimes still add the