0

EDIT

I have created a listview in my homepage, I have written a function to reload the listview in a function called reloadView. Now when I receive a push notification I need to refresh this listview. Currently when I receive push notification I receive a call inside the method pushnotificationhandler() in my applicationui.cpp. So when I receive notification I need to call the reloadView function of homepage to refresh the list and display the homepage. I was able to do this using QMetaObject and the function does gets called but for variables like Color and _settings it shows reference error. Is there anything else I need to declare before hand in cpp to access these variables?

Below is my homepage structure

Page {
    id: menuScreenPage
    objectName: "menuScreenPage"

    // This is the function I need to call from applicationui.cpp
    function reloadView() 
    {
        // shows a reference error on this line
        homePageScroll.getMyContacts(_settings.getArrayFor("contactList", null));
    }

    Container {
        background: Color.create("#9B59B6") // shows a reference error on this line
        layout: DockLayout {
        }
        ScrollView {
            id: homePageScroll

            Container {
                layout: DockLayout {
                }
                ListView { 
                    //somecode
                }
            }
            function getMyContacts(contacts)
            {
                //some code to get contacts
            } 
        }
        attachedObjects:[
            GroupDataModel {
                id: contactsData
                sortingKeys: [ "last" ]
                grouping: ItemGrouping.None
            }
        ]
    }
}

//Trying using metaobject

QDeclarativeEngine engine;
QDeclarativeComponent component(&engine,
          QUrl::fromLocalFile(QFileInfo("app/native/assets/HomePage.qml").absoluteFilePath())));
QObject *object = component.create();

QVariant returnedValue;
QMetaObject::invokeMethod(object, "reloadView");

delete object;
sam
  • 2,780
  • 1
  • 17
  • 30
Francis F
  • 3,157
  • 3
  • 41
  • 79

0 Answers0