[SailfishDevel] State is persistent when I come back to a page, how to avoid this ?
Franck Routier (perso)
alci at mecadu.org
Wed Dec 18 11:03:12 UTC 2013
Thanks Mikko, this works as expected.
As to understanding why the card state persists, do you have any pointer
to readings that would enlighten me ??
Franck
Le 18/12/2013 11:58, Mikko Leppänen a écrit :
> Hi,
>
> You can try something like:
>
>
> onStatusChanged: {
> if (status === PageStatus.Activating) {
> card.state = "hide"; // card = id for card component
> }
> }
>
> Add above statement inside the CardPage.
>
> HTH,
> Mikko
>
>
>
> 2013/12/18 Franck Routier (perso) <alci at mecadu.org <mailto:alci at mecadu.org>>
>
> Hi,
>
> [Disclaimer: I'm still discovering Qt...]
>
> I have a page called CardPage that displays a Card component.
> Card has two states : show or hide. It will change state when clicked.
>
> When first shown, the CardPage sets its Card state to hide. The user
> can click and show the card. So far so good.
>
> Then the user goes back one page, can choose another card among
> several. When a card is chosen, the CardPage is shown again. But then,
> the last Card state is applied. I don't want that, I want to force the
> "hide" state each time the CardPAge is shown.
>
> 1) I don't really understand why/how the Card's state is persisted
> 2) I need to force the state each time the CardPage becomes active,
> and I don't know how to do that.
>
> Here is some code snippets:
>
> CardPage:
>
> Page {
> id: cardPage
> property string source
> property string value
>
> Column {
> width: cardPage.width
> spacing: Theme.paddingLarge
> PageHeader {
> title: "Your card !"
> }
>
> Card {
> source: cardPage.source
> value: cardPage.value
> relSize: 3
> state: "hide" // <-- I want this each time the page is shown
> anchors.horizontalCenter: parent.horizontalCenter
> }
> }
> }
>
> Here is how it is called from my main page (where the user chooses
> between several cards):
>
> delegate: Card {
> id: myCard
> source: ico
> value: val
> onClicked: {
> pageLoader.source = "CardPage.qml"
> pageLoader.item.source = myCard.source
> pageLoader.item.value = myCard.value
> pageStack.push(pageLoader.item)
> }
> }
>
>
> Thanks for your help.
>
> Franck
> _______________________________________________
> SailfishOS.org Devel mailing list
>
>
>
>
> <mailto:mleppan23 at gmail.com>
>
>
> _______________________________________________
> SailfishOS.org Devel mailing list
>
More information about the Devel
mailing list