Not Able to view the List MODEL elements From CPP Until After Reloading the Qml Page.
-
I have a qml list used to display the list of networks available whose model is been taken from data() in CPP, I have a created a custom class that inheirts QAbstractListModel which is responsible to take the data from Dbus and then return Qlist accordingly.
In order to access this data in qml I have created a Network plugin using qmlRegisterSingletonType<>.
Coming to the main issue , when Toggling the switch to ON I need to display the list of available networks but when I do this the list is not been shown.
The list only comes up Ones I go back and come to page again i.e. the list is shown only after reloading the QML Page that displays the list.But if a pass an list model which is defined the in the QML page itself then the list elements are visible as expected.Can any one suggest me what needs to be done, so that I can see the list elements that available in the model when I Toggle the network button.
Reference for How I Created the Plugin-
void NetwrokPlugin::registerTypes(const char *uri) { //SettingsController is the custom class which has data() defined in it and NetworkListModel is the plugin name. qmlRegisterSingletonType<SettingsController>(uri, 1, 0, "NetworkListModel", [](QQmlEngine* engine, QJSEngine*) -> QObject* { return new SettingsController(engine); }); }
Code for the List View: -
ListView{ id: root property var networkName: NetworkListModel.name model: NetworkListModel delegate: delegateComponent Component{ id: delegaeteComponent Column { Text { //anchors //name is a parameter that is coming from CPP model text : name!== undefined ? name: "" } Text { text :NetrworkListModel.connectedName === name ? "connected : " } } } Connections { target: NetworkListModel onNetworkNameChanged: { networkName = NetworkListModel.Name; } } }
Thanks In Advance!
-
Code has some issue. I don't this this is working code. Please give us the working code. We will be able to help you.
Also size for the list view is missing. As such code should work. I tried with minimal example by taking the snippets from your code. It works.