QNetworkConfigurationManager and setContextProperty [answered]
asked 2019-08-13 13:14:35 +0200
This post is a wiki. Anyone with karma >75 is welcome to improve it.
I need to keep track on the state of connectivity, and wanted to use QNetworkConfigurationManager for that.
In the main c++ I have this (stripped down):
int main(int argc, char *argv[]) {
QGuiApplication *app = SailfishApp::application(argc, argv);
QQuickView *view = SailfishApp::createView();
QNetworkConfigurationManager ncm;
view->rootContext()->setContextProperty("ncm", &ncm);
view->setSource(SailfishApp::pathTo("qml/harbour-currencyconverter.qml"));
view->showFullScreen();
return app->exec();
}
When I try to use it from QML as in console.log('From ncm:', ncm.isOnline())
it prints TypeError: Property 'isOnline' of object QNetworkConfigurationManager(0xffefeca8) is not a function
I looked at this, but as I see it I'm doing exactly like it and the documentation says - but I have been proven wrong many times ;)