Hi Gabriel

There are several ways of passing data between Cover and rest of app (or
any components). You can try using app global object ids or javascript
files with .pragma library and gloval [to them] variables or inject global
objects from C++ via setContextProperty().

The way I like doing it is to keep shared object in main.qml and pass it to
pages/covers at the moment of instantiation the following way:

========
ApplicationWindow
{
    id: app
    property string sharedValue: "whatever you want to share to cover"


    initialPage: Component {
        MainPage {
            torch: app.sharedValue
        }
    }

    cover: Component {
        CoverPage {
            torch: app.sharedValue
        }
    }

}
========

I hope if helps.

Cheers,
Artem.



On Sat, Nov 16, 2013 at 1:00 AM, Gabriel Boehme <
m.gabrielboe...@googlemail.com> wrote:

> Hi Sailfish sailors,
>
> I want to ask, what is recommended/best practice to handle different
> covers/covers with dynamic information.
>
> My case:
>
> On the main page (MainPage.qml) you can select some options and search
> depending on the selected options. My main cover shows the selected
> options if minimized, so I can't just create it with
> Qt.resolvedUrl("path/to/maincover.qml"), because I'm "talking" to the
> cover with via property aliases. So I'm creating this cover directly as
> an instance in ApplicationWindow.
>
> After the search a ListView shows the results from a model and I created
> another cover to switch between the results with CoverAction (show
> next/previous) - it takes the data from the model. But also shows some
> information from main page - via property alias.
>
> So the point is: to fill the cover pages with the dynamic data I can't
> create them with Qt.resolvedUrl("path/to/cover.qml"), or
> push("mypage.qml") because I need property aliases to set the
> information on the covers. But in the most examples and also the console
> output tells me, that it is not clever to create instances in the
> ApplicationWindow part.
>
> So what is best practice? Do I miss something?
>
> Thank you very much in advance.
>
> Gabriel
>
> _______________________________________________
> SailfishOS.org Devel mailing list
>



-- 
Artem Marchenko
http://agilesoftwaredevelopment.com
http://twitter.com/AgileArtem
_______________________________________________
SailfishOS.org Devel mailing list

Reply via email to