GroupDataModel as Q_PROPERTY

Hello

Maybe, I am interested in this the wrong way, but is it possible to have a GroupDataModel like a Q_PROPERTY? I want to be able to update the data model via a WebService in C++ with JSON analysis, etc. - and then use the property of NOTIFICATION of it to react in QML. I did it successfully with other types of data, but with GroupDataModel, even though I have

#include - I am just completely unable to see GroupDataModel as an object type in the header files. I just get "GroupDataModel does not name a type" etc. There may be something that I am missing.

If anyone else has tried this? Thank you!

Oh, my apologies - all the time I forgot to add this to the top of my header file:

using namespace bb::cascades;

Tags: BlackBerry Developers

Similar Questions

  • Question simple signal...

    I am trying to hang a simple signal with no params... But I can't get my hands on the appropriate syntax!

    The example I'm looking at has the following syntax:

    class MyDataModel: public bb::cascades::GroupDataModel
    {
    Q_OBJECT
    
    Q_PROPERTY(QString myField READ myField WRITE setMyField
        NOTIFY myFieldChanged)
    ...
    
      void myFieldChanged(QString value);
    
      QString myField ();
    
    signals:
      void myFieldChanged(QString value);
    

    In QML, connect the signal by using the following:

      onMyFieldChanged:
      {
        // When the signal is fired.
        console.log("onMyFieldChanged()");
      }
    

    I would add two new signals, but the two signals do not need to read and write properties...

    signals:
      void dataFetchStart();
      void dataFetchEnd();
    

    What would the syntax required in the my*.h file... The following syntax does not cause the compiler throw high... but that I can't plug my signal in QML...

    Q_PROPERTY(NOTIFY dataFetchStart)
    Q_PROPERTY(NOTIFY dataFetchEnd)
    

    Just use:

    Q_SIGNAL dataFetchStart() etc. instead of Q_PROPERTY. The property is of values that you want to propagate to QML.

  • Stunts by the way of GroupDataModel of c ++ qml problem!

    Hello

    I'm trying to access the data of GroupDataModel of c ++ to qml!

    I tried,

    in PHP,.

    public Q_SLOTS:

    BB::Cascades:GroupDataModel load_datamodel (const QString & txprofile);

    in the PRC,

    BB::Cascades:GroupDataModel ApplicationUI::load_datamodel (const QString & txprofile)

    {

    Model GroupDataModel;

    .......

    model.insertList (()) list.value;

    return the template;

    }

    But it's not working! Please help me!

    I guess that you see no changes when the DataModel is updated?  I recommend to expose to as a Q_PROPERTY QML like this:

    Q_PROPERTY(bb::cascades::DataModel* model READ model NOTIFY dataModelChanged)
    
    public:
    
        YourClass(QObject *parent = 0);
    
    Q_SIGNALS:
    
        /*
         * This signal is emitted the data model is updated.
         */
        void dataModelChanged();
    
    private:
    
        bb::cascades::DataModel* model() const;
    
        bb::cascades::GroupDataModel* mDataModel;
    

    Side C++ you can then pull the signal of dataModelChanged after the model has been changed and you want to update your user interface.

  • the number of elements in the groupdatamodel sections

    I have a listview that has attatched a groupedDataModel.

    The groupedDataModel has 3 sections,

    first elements of article 5

    second of 6 elements

    third to 8 items

    How can I find the number of items in the sections groupdatamodel in QML?

    myList.dataModel.childCount (i); always seems to return the number of sections (3) regardless of the value of i.

    I looked at the documentation, but it doesn't seem as if it was possible. It would be nice to have a getGroup (index) method or something and who gets a QVariantList with all the elements within that group.

  • synchronization of a GroupDataModel

    Hey. I have an application with a user interface and a headless service project project. There QSettings, and also a GroupDataModel. I use the QSetting sync() so that they communicate with each other for the parameters. The GroupDataModel done the same thing in itself?

    See you soon

    Justin D.

    you would have to save the data somewhere, whether in QSettings, a json or in a sqlite database, where the part without head can read.

    the datamodel is part of the user interface and not accessible from the part without a head.

  • How can I fixed listView header in GroupDataModel.

    Hello

    I want to set my header of the listview as a guess I put the listView header in GroupDataModel (Group: ItemGrouping.ByFirstChar). and now when scroll us in listview header must be fixed on what is the current title of the item in the listview. like Blackberry Hub.

    Thank you

    You can use the sample to reach this.

    dataModel: GroupDataModel {
                    grouping: ItemGrouping.ByFirstChar
                    sortingKeys: [ "title" ]
                }
                layout: StackListLayout {
                    headerMode: ListHeaderMode.Sticky
                }
    
  • Expose the QGeoAddress with Q_PROPERTY object to QML

    Hello

    I have a class that I wrote which gets the location of the device and does a reverse search for Geolocation. In my C++, I have an QGeoAddress object, but when I try and access its attributes of QML, I get a "property: unknown type: address QGeoAddress ' error."

    I'm loading my class, called LocationInformation in QML by using attachedObects:

    attachedObjects: [
            LocationInformation {
                id: locationInformation
            }
        ]
    

    In my head of class LocationInformation, I set the latitude and longitude as attributes such as address:

    class LocationInformation : public QObject
    {
        Q_OBJECT
    
        Q_PROPERTY(double latitude READ latitude)
        Q_PROPERTY(double longitude READ longitude)
        Q_PROPERTY(QGeoAddress address READ getAddress)
    
        ...
    }
    

    I am able to call locationInformation.latitude and get a value, but this isn't the case for the address. I have to perform an extra step in order to obtain an QGeoAddress object to be recognized by QML?

    Thank you

    javabb

    QGeoAddress inherit from QObject, my code snippet above will not work (and is what this error means ).  To expose to QML, you would have to wrap up in your own C++ class that extends from QObject.  Or just use c++ instead of QML.

  • GroupDataModel - update the Chronogram of loop without going through a row.

    Hello

    I need to update a child recordset within a GroupDataModel. At first, I update the selected record, but there may be a notebook of the child requiring an update of data in order to take account of the appropriate user interface.

    So I loop trought all of my folders and find those corresponding, but the problem I do face is updateItem() method requires a row position. I guess I have to build the path to the index? Or y at - it another way to update the corresponding records?

      // Extract all records
      QList records = m_dataModel->toListOfMaps();
    
      // Loop and start looking for any possible match
      for (int i = 0 ; i < records.size(); i++)
      {
        QVariant record = records.at(i);
        QVariantMap map = record.toMap();
    
        if ()
        {
          map["myField"] = QVariant("Updated Record");
          // UpdateItem requires an indexPath... but since I'm looping throught       // each item the indexPath is unknown.      //m_dataModel->updateItem(indexPath, itemMap);
        }
      }
    

    OK, thanks for the pointer... I did some research some of the example project, but @ the end I found this thread...

    https://supportforums.BlackBerry.com/T5/native-development/GroupDataModel-how-to-find-an-item-and-GE...

    ... and @ there end, I used this approach:

      // Extract all records  QList records = m_dataModel->toListOfMaps();
    
      // Loop and start looking for any possible match  for (int i = 0 ; i < records.size(); i++)  {    QVariant record = records.at(i);    QVariantMap map = record.toMap();
    
        if ()    {      // Search for this matching record...      QVariantMap matchMap;      matchMap["Field1"] = map.value("Field1").toString();      matchMap["Field2"] = map.value("Field2").toString();      matchMap["Field3"] = map.value("Field3").toInt();      QVariantList indexPath = m_dataModel->lowerBound(matchMap);
    
          // Now that we have determined the index path, we must update the record...      QVariantMap itemMap = m_dataModel->data(indexPath).toMap();      itemMap["FieldToUpdate"] = QVariant("Updated Record"));      m_dataModel->updateItem(indexPath, itemMap);    }  }  
    
  • GroupDataModel formatting header text

    I would like to know if it is possible to format the header in a GroupDataModel somehow?

    I have a GroupDataModel which groups them by Date (a QDateTime). But I don't want an output like: 2012-10 - 01 T 10: 02:48, I want to have it as "01/10/2012".»

    Is this possible? Or what I could do?

    Yes, you are totally right. I forgot that it is not possible to use all of the properties of ListItemData when working with the headers, I don't know the reason.

    I also think that you need to create a custom GroupDataModel. I'm not in custom GroupDataModels nor, but take a look at this example (well he uses a DataModel, not GroupDataModel):

    http://supportforums.BlackBerry.com/T5/Cascades-development-knowledge/using-your-own-DataModel/Ta-p/...

    I hope that helps!

  • get a custom by a GroupDataModel object

    Hey gang,

    I have a GroupDataModel that I fill like this:

    m_model->insert(new Task(lineList.at(3), lineList.at(0), 11223344, lineList.at(2), true));
    

    in a loop.  There will be several objects "Task" in the GroupDataModel.

    What I am not clear is how to get a specific "task" out of the GroupDataModel.

    I tried to use toListOfObjects(), but I don't know how to use it.

    I can't find good examples, although there is some for toGroupOfMaps().

    anyone able to help?

    THX,

    J

    Try this

    toListOfMaps

    QList list = m_model->toListOfMaps();
    
    foreach(QVariantMap item, list){
        // here is logic for compare/find the item by the any value
        if (item["your key"] == your condition){
            //here is your find item
        }
    }
    

    Even logic, you can use toListOfObjects, but instead of QVariantMap use your task object.

    QList list = m_model->toListOfObjects();
    
    foreach(Task *item, list){
        // here is logic for compare/find the item by the any value
        if (item->youkey == your condition){
            //here is your find item
        }
    }
    

    May be a better solution, but hope this works will

  • GroupDataModel how to search for an item and row

    Hi all!

    I have a problem with GroupDataModel.

    I create and fill out the template as below:

    
    m_model = new GroupDataModel(QStringList() << "displayName", this);
    ...
    QVariantMap entry;
    entry["contactId"] = QString::number(contact->getId());
    entry["displayName"] = contact->getDisplayName();
    entry["icon"] = contact->getSmallPhoto();
    
    m_model->insert(entry);
    

    After I cath some report like contactDeleted (int id) and want to remove the related item of the model:

    void ContactsViewModel::onContactDeleted(int id)
    {
      //QVariantList indexPath = m_model->lowerBound(QVariantList() << QString::number(id));
      //QVariantList indexPath = m_model->lowerBound(QVariantList() << id);
      //QVariantList indexPath = m_model->find(QVariantList() << QString::number(id));
      QVariantList indexPath = m_model->find(QVariantList() << id);
    
      if (!indexPath.isEmpty())
      {
        m_model->removeAt(indexPath);
      }
    }
    

    But model will always return row to the first article! I used and GroupDataModel::find and GroupDataModel::lowerBound, but result is still the same!

    Please help me, how can I find point correct?

    Hello

    My understanding of the documentation, it is possible to search only the fields that are in sortingKeys.

    I think that GroupDataModel is the construction of indexes on these areas.

    I did some tests:

    If displayName is present in sort keys:

        GroupDataModel *model = new GroupDataModel(QStringList() << "displayName", this);
    
        QVariantMap entry;
        entry["contactId"] = "100";
        entry["displayName"] = "Alex";
        entry["icon"] = "icon1.png";
        model->insert(entry);
    
        entry["contactId"] = "200";
        entry["displayName"] = "Andrew";
        entry["icon"] = "icon2.png";
        model->insert(entry);
    

    then by displayName will work correctly:

    QVariantList indexPath = model->find(QVariantList() << "Andrew");
    qDebug() << "indexPath" << indexPath << "\n";
    // this will print (QVariant(int, 0) ,  QVariant(int, 1) ) which is
    // section 0, item 1
    

    But research by contactId won't work, because it is not present in sortingKeys.

    If you add contactId to sortingKeys:

    GroupDataModel *model = new GroupDataModel(QStringList() << "displayName" << "contactId", this);
    

    then by searching only by displayName will no longer work. Find() maps values to keys, it will only return entries with empty contactId. But lowerBound() can be used instead:

    QVariantList indexPath = model->lowerBound(QVariantList() << "Andrew");
    qDebug() << "indexPath" << indexPath << "\n";
    // this will return:
    // indexPath (QVariant(int, 0) ,  QVariant(int, 1) )
    

    Please note that the lowerBound is not a complete replacement for find. It returns a suggested for element insertion index. So if she is unable to find a match, it will return (0, 0) like suggested insertion point, but not a row empty.

    When you have multiple sort keys the code depending on type of work to find a name:

        GroupDataModel *model = new GroupDataModel(QStringList() << "displayName" << "contactId", this);
    
        QVariantMap matchMap;
        //matchMap["contactId"] = "200";
        matchMap["displayName"] = "Andrew";
        QVariantList indexPath = model->lowerBound(matchMap);
        qDebug() << "indexPath" << indexPath << "\n";
    

    But if the name is not found lowerBound will return (0, 0) - a proposed insertion point. Is not possible to differentiate the value of return "not found".

    But if you try to provide a contactId

        matchMap["contactId"] = "200";
        //matchMap["displayName"] = "Andrew";
    

    It will not work, because it searches in the order in which the sortingKeys have been reported.

    In this case, it will try to 'empty' QVariant DisplayName of match, find nothing and will be (0, 0) return as insertion point proposed without even trying to match contactId-s.

    The find() function is not appropriate as well because it performs the exact match on all fields and requires that all sortingKeys to be defined.

    I hope I have not confused you completely now!

    So, the conclusion seems to be:

    Find() cannot find an exact match and compared all the keys of the supplied with keys in sortingKeys. If values are omitted it is expected that they are NULL in the model.

    lowerBound() returns a suggested insertion or (0, 0) point, if nothing has been put in correspondence. He compares the values passed to it with the sort of keys from left to right (if the first sortingKey did not match it does not compare).

    If these methods are not well suited for finding a specific key value. A possible workaround is an iteration model entries manually and by comparing their values, but it's slow.

    I suggest to create your own datamodel by inheriting from the class DataModel. It is not very difficult, and you can implement any kind of search in there.

  • Possible outcome - QVariantMap - GroupDataModel

    Not sure, but could be a possible problem:

    It seems that QVariantMap mess up if any key other than "countryName", "CityName" is used.

    I tried in my sample program also tried to change the code to:

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

    Creating a GroupDataModel in C++

    It would be good if someone else can confirm also.

    As a result, registered problem

    https://www.BlackBerry.com/jira/browse/BBTEN-109

    Let me know if you count details

  • How to dynamically change an element in the GroupDataModel?

    I have the controllor custom as the checkbox on each row of a listview. When I check or uncheck the check box, I need to update the data with the row in GroupDataModel. I tried to change the property directly in the ListItemData, but it cannot be changed. I think I should browse the GroupDataModel and find that data, and then update it. Does anyone know how to realize this way cascading only? Thank you.

    I understood how to retrieve the group header element and child elements. I can also update any element children in the GroupDataModel.  If you have a better solution, please let me know. Thank you

    Please see my source code.

    for(var i=0; i < xxxDataModel.size(); i++ ){
        var indexPath = new Array();
        indexPath[0] = i;
        var headerItem = xxxDataModel.data(indexPath);
        if (headerItem != null){
            var childCount = xxxDataModel.childCount(indexPath);
            for (var j=0; j		   
  • QVariantMap in GroupDataModel - how to save and load

    Hello

    I have a GroupDataModel called _entries with QVariantMaps inside:

        QVariantMap entry;
        entry[key_1] = some_qstring;
        entry[key_2] = some_int;
        entry[key_3] = some_datetime;
    
        _entries->insert(entry);
    

    My question is how to store this file?

    Record appears to be simple:

    QFile entriesFile(g_entriesFilePath);
    QDataStream stream(&entriesFile); // Open a stream into the file.
    stream << _entries;
    entriesFile.close();
    

    Is this correct? But how to load?

    delete

    QVariantMap entries = list.toMap();
    

    and to do this

    QVariantList list = jda.load(g_entriesFilePath).toList();
    

    then scroll through the list

  • How to apply filters to the Listview created using GroupDataModel?

    Hello

    I have created a listview with groupdatamodel, now I want to apply filters for listview. How to do this?

    Please help me. (As looking for contacts)

    Kind regards

    Naresh Kodumuri.

    Hello

    I found the solution for the application of filters to the listview.

Maybe you are looking for

  • Qosmio X 70-B-10 t - need a key to install Windows 10

    Hello I have two problems: -Sticker Windows isn't on my computer since I bought my laptop (15 days ago) and I need to install Windows 10-My laptop seems to not be in the database of Toshiba, then when I want to contact Toshiba, my laptop is not recog

  • C7280 print double-sided

    Just installed my new Photosmart C7280.  Seems to work OK except for 2-sided.  Says that the module is not installed.  I made sure that device 'installed' mean to the duplex unit settings; The unit, I took leave and replace it to make sure it is on s

  • Flashing monitor

    The power button on my Dell monitor started blinking on and outside, with no visible image, except a brief flash of light. I am running Windows XP and I use service pack 2. (I had a bad experience, installation of other service packs, so I am wary of

  • Any other player Sansa play files FLAC?

    I got a SanDisk Sansa Clip 4 GB MP3 player thinking he would play files FLAC, but they are being denied when I try and drop them in the drive. One of the players play files FLAC? Thank you.

  • Problems with .dll and WPD files Volumn Driver Windows files is installed but does not work

    I wondered about the .dll files... I have internet explore as a default package as well as Java (TM) web start launcher by Oracle. Can you suggest other programs. I have all the Adobe programs. I would really be able to bind the DLLs of Visual Basic.