[SailfishDevel] C++ and QML Integration: SetContextProperty with the latest SailfishOS Templates
christopher.lamb at thurweb.ch
christopher.lamb at thurweb.ch
Mon Dec 16 21:00:34 UTC 2013
Hoi Thomas
Thank you for your answer.
Zitat von "Thomas Perl" <th.perl at gmail.com>:
>
> As described on the QScopedPointer documentation page:
> http://qt-project.org/doc/qt-5.0/qtcore/qscopedpointer.html
>
I found that a few nights ago. I could not get to sleep, and it
occurred to me that there might be some documentation "out there" that
would a) enlighten me on QScopedPointer and b) send me to sleep.
Suffice it to say that both goals were achieved 8-)
Zitat von "Thomas Perl" <th.perl at gmail.com>:
>
> You probably want to write "return app->exec();" at the end, so that
> your main() function returns a value (and using the app->exec() result
> for that is a good idea).
>
Ok, that also makes sense. Combining everything, I think I will opt for:
int main(int argc, char *argv[])
{
bool simulator = true;
QScopedPointer<QGuiApplication> app(SailfishApp::application(argc, argv));
QScopedPointer<QQuickView> view(SailfishApp::createView());
view->rootContext()->setContextProperty("cppproperty", cppproperty);
view->setSource(SailfishApp::pathTo("qml/SetContextPropertyQt5.qml"));
view->show();
view->showFullScreen();
return app->exec();
}
And given that main is short, I don't think the typedef version brings
any benefits (but that was a tongue-in-cheek suggestion wasn't it?).
Thanks
Chris
More information about the Devel
mailing list