[SailfishDevel] State is persistent when I come back to a page, how to avoid this ?
Mikko Leppänen
mleppan23 at gmail.com
Wed Dec 18 10:58:18 UTC 2013
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>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> 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
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.14 (GNU/Linux)
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>
> iQEcBAEBAgAGBQJSsXt2AAoJEGEvoAir78RoCQ8IALT5P8OAXOyiW18b9tdCr9Qo
> oHT5fDZqbUQ3ZRCe1pbrzajnBtmqXgXX2tl8P2weh752AeXhoEF+7pXikfe15YXD
> Q/hJ9qJbuhyeQFx7wlmE6Lzuq3Y3nWthdgZhHT56XYIj8wbz4GJZdmhxaaHJsLwr
> 7jID1N0m24OqiNe3QjhaII5VbS1bP81ZwlhQpndDQujcFu31EJvaN23KeB1DtGkm
> blN+EzDRBUL08cRELszVM7Hb9DlljzOkoSiRMchjQ2rlaSyun/FMUPvYUXYA3rtG
> YS80YYkDyou9JHvU14c61TnXL3ioXyy+9+5XWzDaXt5FHNE/RrfGApaiELVE8C0=
> =wp1L
> -----END PGP SIGNATURE-----
> _______________________________________________
> SailfishOS.org Devel mailing list
>
<mleppan23 at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.sailfishos.org/pipermail/devel/attachments/20131218/13318cf6/attachment.html>
More information about the Devel
mailing list