<html><body><div style="font-family: times new roman, new york, times, serif; font-size: 12pt; color: #000000"><div>Hi,<br></div><div><br></div><div>While that solution below works perfectly fine to get data from the appWindow to the cover, I am facing an issue trying to do the opposite.<br></div><div><br></div><div>Let's explain. My AppWindow looks like this:<br></div><div><br></div><div style="padding-left: 30px;">ApplicationWindow<br>{<br> MyModel {<br> ...<br> onUpdated(cover.myFunction())<br> }<br></div><div style="padding-left: 30px;"><br></div><div style="padding-left: 30px;"> cover: Qt.resolvedUrl("cover/CoverPage.qml")<br> ...<br>}<br></div><div><br></div><div>in CoverPage.qml I have the following:<br></div><div><br></div><div style="padding-left: 30px;">CoverBackground {<br>...<br> myFunction(){<br> ...<br> }<br>}<br></div><div><br></div><div>I am unable to execute myFunction for whatever reason I don't understand. I also tried a few things like:<br></div><div style="padding-left: 30px;"><br></div><div style="padding-left: 30px;">import "cover'<br></div><div style="padding-left: 30px;"> MyModel {<br> ...<br> onUpdated(coverPage.myFunction())<br> }</div><div style="padding-left: 30px;">cover: CoverPage {id: myCoverPage}<br></div><div><br></div><div>Weird that in that case the font used by the cover is not the regular Sailfish font...<br></div><div><br></div><div>It is the same to access properties from the cover. How is it supposed to work?<br></div><div><br></div><div>Thanks,<br></div><div><br></div><div>Antoine<br></div><div><br></div><hr id="zwchr"><div><br>De: "Andrey Kozhevnikov" <coderusinbox@gmail.com><br>À: devel@lists.sailfishos.org<br>Envoyé: Samedi 16 Novembre 2013 08:48:05<br>Objet: Re: [SailfishDevel] best way to work with covers?<br></div><div><br></div><div>If you declare all your pages in ApplicationWindow like:<br></div><div><br></div><div>ApplicationWindow {<br> id: appWindow<br> cover: Qt.resolvedUrl("CoverPage.qml")<br></div><div><br></div><div> MainPage {<br> id: mainPage<br> }<br></div><div><br></div><div> SecondPage {<br> id: secondPage<br> }<br>}<br></div><div><br></div><div>then you can use pages global properties and functions from CoverPage:<br></div><div><br></div><div>CoverBackground {<br> id: cover<br> ...<br></div><div><br></div><div> Label {<br> anchors.centerIn: cover<br> ...<br> text: mainPage.processStatus<br> color: secondPage.getCoverColor()<br> }<br>}<br></div><div><br></div><div>On 16.11.2013 13:39, Gabriel Boehme wrote:<br></div><blockquote>Hi Artem,<br><div><br></div> thanks for the fast response.<br><div><br></div> Your solution is a good idea, and could work for some values (main page<br> and first cover) - thanks for that! :), but not all.<br><div><br></div> Because I can pass them only in the moment I instantiate them. So I have<br> to instantiate all of them in the ApplicationWindow. This is possible,<br> but I guess due to the SailfishOS glass effect they appear stacked. So I<br> see other files (pages/cover), even if they are not set as the PageStack<br> first page or Cover. Maybe it's possible to workaround with opacity and<br> checking for PageStatus, but seems not to be the cleanest solution. And<br> the other side is, the console output/examples said, it's better to<br> create them just in the moment you really need them.<br><div><br></div> So I also tried, var page = Qt.createComponent("qml/file"), so I can<br> store a page/cover in a variable and push that on the PageStack, but I<br> can't reach the property aliases.<br><div><br></div> Thanks.<br><div><br></div> Gabriel.<br><div><br></div><br> Am Samstag, den 16.11.2013, 01:55 +0200 schrieb Artem Marchenko:<br><blockquote>Hi Gabriel<br><div><br></div><br> There are several ways of passing data between Cover and rest of app<br> (or any components). You can try using app global object ids or<br> javascript files with .pragma library and gloval [to them] variables<br> or inject global objects from C++ via setContextProperty().<br><div><br></div><br> The way I like doing it is to keep shared object in main.qml and pass<br> it to pages/covers at the moment of instantiation the following way:<br><div><br></div><br> ========<br> ApplicationWindow<br> {<br> id: app<br> property string sharedValue: "whatever you want to share to cover"<br><div><br></div><br><div><br></div><br><div><br></div> initialPage: Component {<br> MainPage {<br> torch: app.sharedValue<br><div><br></div> }<br><div><br></div> }<br><div><br></div><br> cover: Component {<br> CoverPage {<br> torch: app.sharedValue<br> }<br> }<br><div><br></div><br> }<br><div><br></div> ========<br><div><br></div><br> I hope if helps.<br><div><br></div><br> Cheers,<br> Artem.<br><div><br></div><br><div><br></div><br> On Sat, Nov 16, 2013 at 1:00 AM, Gabriel Boehme<br> <m.gabrielboehme@googlemail.com> wrote:<br> Hi Sailfish sailors,<br> <br> I want to ask, what is recommended/best practice to handle<br> different<br> covers/covers with dynamic information.<br> <br> My case:<br> <br> On the main page (MainPage.qml) you can select some options<br> and search<br> depending on the selected options. My main cover shows the<br> selected<br> options if minimized, so I can't just create it with<br> Qt.resolvedUrl("path/to/maincover.qml"), because I'm "talking"<br> to the<br> cover with via property aliases. So I'm creating this cover<br> directly as<br> an instance in ApplicationWindow.<br> <br> After the search a ListView shows the results from a model and<br> I created<br> another cover to switch between the results with CoverAction<br> (show<br> next/previous) - it takes the data from the model. But also<br> shows some<br> information from main page - via property alias.<br> <br> So the point is: to fill the cover pages with the dynamic data<br> I can't<br> create them with Qt.resolvedUrl("path/to/cover.qml"), or<br> push("mypage.qml") because I need property aliases to set the<br> information on the covers. But in the most examples and also<br> the console<br> output tells me, that it is not clever to create instances in<br> the<br> ApplicationWindow part.<br> <br> So what is best practice? Do I miss something?<br> <br> Thank you very much in advance.<br> <br> Gabriel<br> <br> _______________________________________________<br> SailfishOS.org Devel mailing list<br><div><br></div><br><div><br></div><br> -- <br> Artem Marchenko<br> http://agilesoftwaredevelopment.com<br> http://twitter.com/AgileArtem<br> _______________________________________________<br> SailfishOS.org Devel mailing list<br></blockquote><br> _______________________________________________<br> SailfishOS.org Devel mailing list<br><div><br></div>_______________________________________________</blockquote><div><br>SailfishOS.org Devel mailing list<br></div></div></body></html>