making it work
This commit is contained in:
@@ -10,20 +10,29 @@ int main(int argc, char *argv[])
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
NetworksModel model;
|
||||
qDebug() << "now has " << model.rowCount() << Qt::endl;
|
||||
|
||||
QQuickView view;
|
||||
view.setResizeMode(QQuickView::SizeRootObjectToView);
|
||||
view.setInitialProperties({{"networksModel", QVariant::fromValue(&model)}});
|
||||
view.setSource(QUrl("qrc:/wifipicker/Main.qml"));
|
||||
view.show();
|
||||
QQmlApplicationEngine engine;
|
||||
const QUrl url(u"qrc:/wifipicker/Main.qml"_qs);
|
||||
QObject::connect(
|
||||
&engine,
|
||||
&QQmlApplicationEngine::objectCreationFailed,
|
||||
&app,
|
||||
[]() { QCoreApplication::exit(-1); },
|
||||
Qt::QueuedConnection);
|
||||
engine.load(url);
|
||||
|
||||
if (!view.rootObject())
|
||||
|
||||
QObject *rootObject = engine.rootObjects().first();
|
||||
if (!rootObject)
|
||||
{
|
||||
qDebug() << "No root object found" << Qt::endl;
|
||||
qDebug() << "Problem in finding root object" << Qt::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
QObject *rootObject = view.rootObject();
|
||||
engine.setInitialProperties({{"model", QVariant::fromValue(&model)}});
|
||||
rootObject->setProperty("model", QVariant::fromValue(&model));
|
||||
|
||||
QObject::connect(rootObject, SIGNAL(scanNetworks()), &model, SLOT(scan()));
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user