01-09-2013 04:13 PM
I'm new to QML and Cascades development and I have the following scenario. On my main page, I have a ListView and when a list item is pressed, a new page is created dynamically and pushed onto the navigation stack. I am able to see the new page, but it is blank. The qml code for this new page is defined in a separate file called DirectionViewer.qml. To achieve this, in my main.qml file I have the following snippet of code:
In DirectionViewer.qml, I created another list view and have given it an objectName called directionList. My question is, how can I access "directionList" in C++, such that I can set the dataModel of the list from my C++ code?
Solved! Go to Solution.
01-16-2013 12:58 AM
Youe should use following code in c++ file:
// Retrieve the list so we can set the data model on it once
// we retrieve it
mListView = root->findChild<ListView*>(
01-16-2013 04:43 AM
Write a method in C++ and pass your ListView.
void ListViewUtil::setDataModel(QObject* listViewObject)
In C++ you can cast the QObject to ListView.
ListView listView = dynamic_cast<ListView *>(listViewObject);
Then set the data model.
01-26-2013 01:14 PM