Any sample of "creating a GroupDataModel as QML and C++.

Hello

Of this sample:

https://developer.BlackBerry.com/Cascades/documentation/UI/lists/groupdatamodel.html

// This is the C++ code that populates the data model. You could include this code
// in the constructor for your app, in an initialization function, or another
// location in your app.

// Create the GroupDataModel by locating the corresponding QML component
GroupDataModel *pModel = root->findChild("groupDataModel");

// Insert the data as instances of the Employee class
pModel->insert(new Employee("Barichak", "Westlee", 12596375));
pModel->insert(new Employee("Lambier", "Jamie", 53621479));
pModel->insert(new Employee("Chepesky", "Mike", 65523696));
pModel->insert(new Employee("Marshall", "Denise", 77553269));
pModel->insert(new Employee("Taylor", "Matthew", 51236712));
pModel->insert(new Employee("Tiegs", "Mark", 13112965));
pModel->insert(new Employee("Tetzel", "Karla", 99214732));
pModel->insert(new Employee("Dundas", "Ian", 64329841));
pModel->insert(new Employee("Cacciacarro", "Marco", 54575213));

How can I get Employee of row object in my slot triggered?

void onTriggered(QVariantList indexPath)
{
    GroupDataModel *pModel = root->findChild("groupDataModel");
    pModel->data(indexPath);    //......?????????

    Employee e
}

Nicolas

I found the solution... it's quiet easy.

void onTriggered(QVariantList indexPath)
{
    GroupDataModel *pModel = root->findChild("groupDataModel");

    QVariant item = pModel->data(indexPath);

    Employee *e = (Employee *) item.value();
}

Nicolas

Tags: BlackBerry Developers

Similar Questions

  • Create a ListView in QML and then use it in C++

    Hi all, I've been struggling with QML and C++ integration for some time now.

    I'm at a point where I need a ListView in my application.

    Is it possible for me to create a ListView with its ListItemComponent and DataModel in QML and then use it in my code c ++?

    If so, a kind enough to provide a code sample on creating a QML object and then use it in c ++?

    Thank you very much

    Hey jayvd, there is a "CallaPizza" example call, the documentation links to the example is in the following link

    http://BlackBerry.github.IO/Cascades-samples/callapizza.html

    and you can download the example from github.

    In this example, they use a list written on QML the datamodel is managed on a C++ class, so you can use these same aproach to solve your problem. On the other hand, the propouse of Kanaksony solution might also work, you must have a reference to the object (qml) that contains the ListView, and then find the listView object, using the findChild method, once you have the reference to the list, you get access to all methods of properties.

    Cordially, Cristian.

  • Application crashes when I expose C++ groupDataModel in qml

    Hello world

    in my application, I have discovered in a container list. When I click on one of these items in the list another page is loaded. The user interface is qml. It works very well. But now I want to add data to the page. If I do it crashes without warning or error.

    Here is the part of the code inportant:

    // Main.qml[...]onTriggered: {
                        var selectedItem = dataModel.data(indexPath);
    
                        var page = Qt.app.doLoadPageDetails();
    
                        navigationPane.push(page);
                    }[...]
    

    and here's what the doLoadPageDetails function defined in C++:

    // applicationui.cppPage* ApplicationUI::doLoadPageDetails(){    QmlDocument *qml = QmlDocument::create("asset:///PageDetails/PageDetails.qml").parent(this);
        qml->setContextProperty("app", this);
    
        Page* newPage = qml->createRootObject();
    
        // Create root object for the UI
         AbstractPane *root = qml->createRootObject();
    
         GroupDataModel *contactModel = new GroupDataModel;
            // ----> here I fill the data model with contacts
    
        // Connect to list view and update model
         ListView *contactListView = root->findChild("listContacts");
    
        contactListView->setDataModel(contactModel); <----- here my app crashes
    
        return newPage;
    }
    
    Page{
    ...
      Container{
    ...
        Container{
    ...
          ListView{
    ...
            id: listContacts
            dataModel: groupDataModel
            listItemComponents: [
              ListItemComponent {
                StandardListItem {
                  title: ListItemData.personName
                  description: ListItemData.mail
                  status: ListItemData.more
    ...
                }
              }
            ]
          }
        }
      }
    }
    

    I discovered by messages from debugging the accident happens when I want to inject the data to my page in qml model.

    Another point of my application, it works. But I can't know where the differences are. The only difference that I see so far is that in the other page ListView is inside a container. Not like here the ListView is inside a container which is once again within a container.

    Has anyone an idea what I can try to understand what is the cause of this accident? Without any error message, it is difficult to find the answer.

    Found the solution.

    I forgot to set the objectname in the ListView.

    ...ListView{  id: listContacts
      objectName: "listContacts"}
    

    I thought id would be the link between qml and C++.

  • create component qml and then modify it

    I can create a component dynamically qml of my js, but I have to then check the values of the components.  I can't understand how to do this?  Can I give the created part somehow an id?

    You can give it rather objectName. This thread has some samples of use objectName:

    http://supportforums.BlackBerry.com/T5/Cascades-development/getElementById-in-QML/TD-p/2377935

    Or simply store the instance is created in a property and reference it through this property:

    property myVar variant

    ...

    myVar = xxx.createObject (parent)

    or

    myVar = JSFile.jsFuncCreatingAnObject)

  • A tutorial / sample to create a single PDF of several source files using assembler PDF in a process of control folder.

    A tutorial / sample to create a single PDF of several source files using assembler PDF in a process of control folder. I have a client application that will prepare the number of source files and metadata information (in. (XML) that will be used in the header/footer. Is it possible to set a run time generated shows the DDX file in the folder and use it in the process. If possible how can I pass the file names in the DDX. Any sample process will be very useful.

    If possible, make use of the API of the assembler in your client application instead of doing this using watched folder. Here are examples of the assembler: LiveCycle ES2.5 * programming with LiveCycle ES2.5

    The record can accept zip files (example: configuration of a control folder to manage several input files and write the results to a single folder |) Adobe LiveCycle Blog ). You can also use run the script to create the DDX when executing: LiveCycle ES2 * Application Development using LiveCycle Workbench ES2

    Thank you

    Wasil

  • Create a shortcut on the desktop the icon comes back to a 'globe' for any shortcut, I create. It does not cover the actual icon as shown in the url or web page. Any ideas?

    Create a shortcut on the desktop the icon comes back to a 'globe' for any shortcut, I create. It does not cover the actual icon as shown in the url or web page. Any ideas?

    Hi Ronnie,.

    I see that you can not create a shortcut on the desktop. I'll help you with this problem.

    1. What is the brand and model of the computer?

    2. what operating system is installed on the computer?

    3. what security software is installed on the computer?

    4. have you made changes on the computer recently?

    5 is the issue limited to the creation of shortcuts on the desktop?

    6. How do you try to create a shortcut on the desktop?

    Please provide us with more information to continue troubleshooting as a result.

    See the link on how to ask questions or help on the Forums.

    Suggestions for a question on help forums: http://support.microsoft.com/kb/555375

    Thank you.

  • Any attempt to create results by "Access denied" error zip file

    Windows 7 Professional 64 bit.  I am logged in as administrator.  UAC is not active on this machine.

    Any attempt to create a zip file results in a dialog box stating "unable to complete the operation.  Access is denied. "
    If I select a file or group of files/folders, do a right click and say 'Send to Zip', I get this error.  Interestingly, while the error dialog box is still open, the zip file will be displayed in the current folder.  Clicking OK in the box dialog error cancels the dialog box and deletes the zip file.
    This seems to be some sort of permissions thing.  Can I create a zipfile by clicking right in the Explorer window by clicking on "new", then "compressed (zipped) folder", and it will create the file very well.  I can even give it a name.  Any attempt to copy anything in this new zip file generates an error "file not found or no read permission.  Try to delete the zip file says 'you need permission from administrators to make changes to this file.
    So now, I open the properties for the zip file and go to the Security tab.  It was there that I discovered that this file has no owner are entrusted to him.  I can then change owners, add my name as the owner of the file, assign full control to myself, apply the changes, and now the zip file can be read/written/removed normally.
    So whenever I need to create a zip file, I have to go through the steps of creating-> change the properties of the-> Assign owner-> Apply-> add files to the Zip file.  It's a royal pain in the keester.
    My question is: what changes to do to confide as the owner by default when a zip file is created?  This seems to happen with only zip files, any other type of file gives me this problem.  What happened since I got this computer brand new with Windows 7 64 - bit on it.  I can't say that it is a "Virgin" installation, he was photographed by a group of COMPUTER companies (I work for a fairly large company).  This group is a clue what happens and apparently others in our society do not report this problem.

    Solved! The problem is with the permissions on the 'TEMP' directory which is used during the process of zip. See this announcement and scroll down to "more useful answer.

  • Cannot use the context property in a page created from an another qml with createObject()

                        gestureHandlers: [
    
                            TapHandler {
    
                                onTapped: {
                                    var page = infoPage.createObject();
                                    taskCont.ListItem.view.pushNewPage(page); //this pushes page to navigationPane (function at top of qml)
    
                                }
    
                                attachedObjects: ComponentDefinition {
                                    id: infoPage;
                                    source: "asset:///taskInfo.qml"
                                }
                            }
                        ]
    

    This is how I created the page of 'taskInfo. In the PRC, I registered a context property that I am able to access it from the current page but not in 'taskinfo. "gestureHandlers: []" is "listItemComponents".

    I expect to access the object of 'taskInfo' is because I am able to access it from another page created the same way.

    Here's how to register the context property.

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

    OK, I found my problem.

    The reason why he doestn can't work because the page is pushed out "main.qml".

    This is part of my main.qml

    Container {
                id: main_content
    
                TaskList {
                }
    
            }
    

    TaksList is another qml file. When I createObject from this qml file, somewhy context property is not trafered to this object.

    I've found a workaround. I created a function in main.qml and only now I create object, so the contextproperty is transferred

  • Create a FilePicker for QML images

    I have a FilePicker in QML, and it works, sort of. The type property seems to not be recognized because it displays all kinds of file types.

    attachedObjects: [
        FilePicker {
            id: imgPicker
            title: qsTr("Select a picture")
            type: FileType.Picture
            onFileSelected: {
                imageView.imageSource = selectedFiles[0];
            }
        }
    ]
    

    The type property is used similar to the example of the API:

    https://developer.BlackBerry.com/Cascades/reference/bb__cascades__pickers__filepicker.html

    However, I get the qml errors during execution of the code

    Warning: 14:35:15.118 file:///apps/x/native/assets//materials/x.qml:68: ReferenceError: Can't find variable: FileType
    

    And the FilePicker debug output suggests that it is created with type 'other ':

    Debug: 14:35:23.758 toTypedescList() returned  ("Other")
    Debug: 14:35:23.760  defaultFileNames  ""
    Debug: 14:35:23.766  ViewMode  0
    Debug: 14:35:23.767 The dataMap  QMap(("AllowOverwrite", QVariant(bool, false) ) ( "ImageCrop" ,  QVariant(bool, false) ) ( "Mode" ,  QVariant(QString, "Picker") ) ( "SortBy" ,  QVariant(QString, "Default") ) ( "SortOrder" ,  QVariant(QString, "Default") ) ( "Title" ,  QVariant(QString, "Select a picture") ) ( "Type" ,  QVariant(QString, "Other") ) ( "ViewMode" ,  QVariant(QString, "Default") ) )
    Debug: 14:35:23.790 The request string  "AllowOverwrite:b:false
    ImageCrop:b:false
    Mode::Picker
    SortBy::Default
    SortOrder::Default
    Title::Select a picture
    Type::Other
    ViewMode::Default
    

    What would be the correct type to use?

    FileType.Picture is good according to the docs. FileType is registered as qmlRegisterUncreatableType in your cpp file?

  • How to pass the GroupDataModel of QML to C++ object reference?

    I want to retain the reference to the GroupDataModel by passing QML for C++.

    The side C++ is as follows:

    void App::setCurrentGroupModel (GroupDataModel & groupModel) {}
    currentGroupModel = & groupModel;
    }

    The side QML is as follows:

    app.setCurrentGroupModel (favoriteGroupModel);

    I received the following error message:

    Assets / / hand. QML:246: error: unknown method parameter type: GroupDataModel &

    I'm still learning QML and C++. I was just wondering what I did wrong to receive the above error?

    Thank you!

    You should probably just get a reference to your listview with container-> findChild ("objectName")and then you always have access to the datamodel that sound help

  • In Photoshop CC14, cannot open any file or create a new file.

    I open photoshop (recent and previous update), and it does not allow me to open any files, or create a new. The white screen with tools remains just the same. Other applications such as Illustrator still work. I'm on Windows 8.1. Please help I need Photoshop for my business.

    I can't open or create files. | Error postal codes of Mylenium

    Mylenium

  • Any method to create a total SUM of a column whose values based on LAG?

    I have a question here, and the challenge is to explain my situation well. I am developing a workbook that shows by project and month, the cost of this period and the change in the cost of the previous period. I want a total SUM on the columns of this period cost and cost change in prerequisite Mth. So what I want to do resembles something like this--

    Months of project cost this time Chg prior Mth cost

    ABCDE Jan $50,000 NULL (since no line before)
    ABCDE February $ $75,000 25 000
    Mar $60,000 ABCDE - 15 000
    ------------------------ ----------------------------------------------
    Total of $ $185,000 10 000

    I do the Chg of cost of prior Mth as a new calculation and use the formula insert model process to use the model of the difference f (x) to create my calculation. Who is working just great. If you look at the underlying code for this new section, you can see the LAG function used in the calculation of this value. I'm late to a single line, as you can see in the example above.

    I can create a new total and take a NAP in the cost column this time and get the right answer (the $185 000).

    The problem that I am running is that I get nothing when I try to summarize my prior Mth column cost Chg. The result is just empty (prints the text of the total, but no amount).

    My thought is that the NULL row in this column was to spoil the AMOUNT of work. So, I created a new calculation and said CASES WHERE prior cost Chg of Mth IS NULL THEN 0.00 ELSE cost Chg of Mth prior. So I get a new column with the same numbers, except for the first line, where I now have a 0 instead of NULL. Then, I created a new total (SUM function) on this new column. Heck. Same result with regard to the other column. I do not receive an amount.

    Everybody run on an issue to try to sum a column of numbers being calculated from a SHIFT function in discoverer? Any suggestions on how I could get a SUM to calculate correctly to this column cost Chg prior Mth? Or have I met one of those irritating questions "cannot manage in discoverer?

    Of course I can export the workbook results run to Excel and create the calculation in there, and that works fine.

    John Dickey

    Hi John
    Thanks for the question and great information. That really helped. I love this kind of questions. They make me think :-)

    Just a thought but have you tried to change the AMOUNT for a sum of CELL?

    The SUM will try to assess the LAG on the total that would be invalid as, at least in theory, the SUM of the CELL must literally add the values.

    Best wishes
    Michael

  • Error message: cannot create the folder C:\Documents and Settings\Marlon\Local Application BVRP Software\NetWaiting\MoHlog.txt Settings\

    I recently had a problem with the virus 'Restore Windows'. I was able to get rid of it with Malwarebytes antivirus scanner, but when I turn on my computer I get this error message.
    Cannot create the folder C:\Documents and Settings\ of Settings\Marlon\Local Application BVRP Software\NetWaiting\MoHlog.txt

    I'm no expert, but I feel that my C drive disappeared, or at least has been hidden. My documents, pictures and music files are all empty. My programs (start > all programs) have been removed and deleted the shortcuts on the desktop. When I go to my computer, my personal and shared document files are not accessible. Under the description it says that they are hidden. My local disk (c) is also empty, but there is still very little space which suggests that programs and files have not been deleted.
    Is it possible to recover my files?
    Thank you

    Hello

    MoHlog.txt file is related to the software of modem on the computer, you can uninstall and reinsta it check if it works.

    Also scan your computer for any infection by virus still present on the computer using any scanner online.

    You can also try the system restore to the point before that the computer has been infected by the virus and check if it helps.

    Good luck!

  • Move the user off the system disk folders? Envy of all the data on E, so need to move directories user E. not individually, but in the world. If all new users, I create will have their user and docs folder on E.

    Got a new laptop with win 7 home premium pre-installed. Using the language of win 7... I have decreased the volume of HDD to 55 GB.  Made new simple volumes. I want all the data personal on E, so need to move user directories to E. No individually change the location tab on dozens of files, but in the world. If all new users, I create will have their user and docs folder on E from the gitgo.

    Under XP, I could just change the 'My Documents' link on each desktop, go to the e. * instead of c *. *, but with win7?

    As a Windows Home Server and most wise OS facilities, the system drive is isolated and a drive of 2 or 3 for everything else.  Get a problem? Just restore the system drive.

    You need the answer?

    Thank you
    Tom
    PS Microsoft: This backup/do imaging software, why don't we name the image so many can all be stored on easily in one place without having to go and rename it or move them elsewhere?

    Hello TomZork,

    Thanks for posting on the Microsoft answers Forum.

    In another forum, I found the instructions to move folders of users to another drive.
    You can follow the post here. This is attributed to Jimmie R. Houts.

    Article:
    You can move the entire folder C:\Users to another drive quite easily once windows is installed:

    1. Boot from the installation media and access the command prompt (I think you need to click on fix everything first)
    2. Use Robocopy to copy C:\Users to D:\Users: robocopy c:\Users d:\Users /mir /xj
      a. /mir says robocopy to mirror directories, this will copy all files and permissions
      b. /xj is very important, it means robocopy does not follow the points of junction. If you forget this, you will have a lot of trouble.
    3. Make sure that the files copied successfully
    4. Delete c:\Users
    5. Create the junction pointing d:\Users: mklink /d c:\Users d:\Users

    That's all. I used this process for Vista RTM with no problems.

    Here's an article that explains as well. Just use robocopy instead of xcopy as it does in the article in order to avoid possible ntfs permissions problems.

    Update: because I discovered the hard way, I thought I would mention also that if you plan on switching "Program Data", or "Program Files" with this method, you will be disappointed to know that everything works as expected, but the windows updates will install is no longer. I don't know if this problem has been fixed in Win 7.

    With the foregoing, it is not a Microsoft forum or Web site so you will have to use at your own risk. I also recommend to do a system restore point before making any changes in directories that you can then go back to a previous state.

    Please reply back and let us know if these suggestions help you to solve your problem, then to benefit others.

    Sincerely,

    Marilyn
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think

  • On the QML and C++ integration (getting "undefined")

    This subject has been discussed often and I went through a lot of discussions, but I have not found a solution for my problem so far.

    What I want to do in my application:

    I have a container that displays an html page. No, I want a part of the html page dynamically filled a C++ function. Here is my Code:

    // HTMLCreator.hpp
    
    #ifndef HTMLCREATOR_HPP_
    #define HTMLCREATOR_HPP_
    
    #include 
    
    class HtmlCreator : public QObject{
    Q_OBJECT
    Q_PROPERTY(QString html READ html WRITE setHtml NOTIFY htmlChanged)
    public:
        HtmlCreator(QObject *parent = 0);
        ~HtmlCreator();
    
        Q_INVOKABLE QString html();
    
        Q_INVOKABLE void setHtml(QString html);
    
    signals:
        void htmlChanged(QString);
    
    private:
        QString m_html;
    };
    
    #endif /* HTMLCREATOR_HPP_ */
    
    // HtmlCreator.cpp#include "HtmlCreator.hpp"
    #include 
    
    QString HtmlCreator::html(){
        return m_html;
    }
    
    void HtmlCreator::setHtml(QString html){
        if(html != m_html) {
            m_html = html;
            emit htmlChanged(m_html);
        }
    }
    
    // applicationui.cppPage* ApplicationUI::doLoadPageDetails(){
    
        qmlRegisterType("myHtmlCreator", 1, 0, "HtmlCreator");
    
        QmlDocument *qml = QmlDocument::create("asset:///PageDetails/PageDetails.qml").parent(this);
        qml->setContextProperty("app", this);
    
        HtmlCreator *HtmlCreator = new HtmlCreator();
        qml->setContextProperty("HtmlCreator", HtmlCreator);
    
        Q_INVOKABLE QString HTMLString = "";
    
        HTMLString.append("
    A
    a
    "); HTMLString.append("
    B
    b
    "); MinutesData->setHtml(HTMLString); Page* newPage = qml->createRootObject(); AbstractPane *root = qml->createRootObject(); return newPage; }
    // PageDetails.qml
    
    import myHtmlCreator 1.0
    
    Page{[...]Container {
            layout: DockLayout {
            }
            horizontalAlignment: HorizontalAlignment.Center
            verticalAlignment: VerticalAlignment.Top
    
            ScrollView {
                id: scrollView1
                scrollViewProperties {
                    scrollMode: ScrollMode.Vertical
                }
                layoutProperties: StackLayoutProperties {
                    spaceQuota: 1.0
                }
    
                scrollViewProperties.pinchToZoomEnabled: false
                scrollViewProperties.overScrollEffectMode: OverScrollEffectMode.None
    
                visible: true
                WebView {
                    id: webViewScrollable1
    //                url: "local:///assets/examples/test4.html"
    
                    settings.viewport: {
                        "initial-scale": 1.0
                    }
                    settings.zoomToFitEnabled: false
                    settings.textAutosizingEnabled: false
                    settings.defaultFontSizeFollowsSystemFontSize: true
                    settings.imageDownloadingEnabled: false
                    settings.binaryFontDownloadingEnabled: false
                    settings.cookiesEnabled: false
                    settings.javaScriptEnabled: false
                    settings.activeTextEnabled: false
    
                    html: " ...  lots of html code displayed correctly" +
                    HtmlCreator.html +
                    "" +
                    ""
                }
            }
    

    Now to the point where with HtmlCreator.html do I put her thong in the app I see "undefined" text

    What I'm doing wrong here?

    I found the solution!

    I missed to add my class as an attached object. So the container, the label or in my case WebView where I want to use the Q_Properties defined in my class, I have to add:

    attachedObjects: [
      HtmlCreator {
        id: htmlCreator
      }
    ]
    

    and then I can get the property

    htmlCreator.html
    

    But unfortunately
    the string I get is empty, so I'm still something missing here.

Maybe you are looking for

  • timeout iOS Autolock lost 9.3 options

    Updated my iPhone 6 over yesterday for the last iOS 9.3.  Options lost for the time of inactivity before automatic locking takes place - stuck (in gray) to 30 sec.  I can find the options for the other kick in time - 1 min, 5 min, never, etc.. ?

  • Disable the ALS on X120e

    This has been driving me crazy since I bought this laptop. I want the sensor of ambient light off, but I couldn't find a way to do it. Can someone help me please.

  • How to open a *.mlog file in Windows XP

    When I ran IBM ThinkVantage program Rescue and Recovery and restored a backup of the system to the system of Windows XP SP3, I had instead of my Outlook.pst file *.mlog files. When I try to open .mlog file, menu appears. If I click on "With" and do a

  • Download and install apps through security securityu, anti-viral and firewall settings

    Hi, you guys. I'm still here and still need the same help. I can't download apps. as Amazon games and software downloader or Kindle for PC application. I get "your security settings do not download this file." If I go to my downloads folder and try t

  • Connection Bluetooth Z10 blackBerry blue car

    I have an Audi A7 2013 and my Z10 easily reached connectivity but I can that make calls through the car kit, not to receive them. My wife has a VW 2013 and I don't have this problem in his car. Another cel phones i.e. Blackberrys B10 before work as d