-
Binding 2 QML pages
Hi
I'd like to know how to bind A.qml to B.qml, so that B returns a value to A.
The context :
A.qml is my main page, and both A and B are Page based (I'm using pageStack to push B)
B.qml is a filebrowser, and I would like it to return the filename when the file is selected.
The PageStack Element documentation specifies that binding pages should be privilegied to use of parameters. Here, my issue is not passing a parameter from A to B, but, B being pushed by A, from B back to A, before popping B.
Signal could be a solution, but it doesn't sound "high-level" enough for my QML approach.
I've tried to create a property in A.qml, but it isn't seen by B.
How should I handle this information transfer from a page to another issue?
thanks
-
Re: Binding 2 QML pages
my solution for this would not be great but it works for me :)
What you can do is :
1. Make two global propertie in main.qml say bState and selectedFileName.
2. Handle the onStatusChanged signal in page A, and if your page's status is 2 , that means page is activated so check for that status inside onStatusChanged.
3. when you pop page B set the global property bState to true and assign selectedFileName with the actual Filename selected in Page B.
4. Lastly just use bState and selectedFileName in Page A.
Sample Code on Page A:
[CODE]onStatusChanged:{
if(status == 2 && bState){
use selectedFileName here
}
}[/CODE]
I hope you understood what i want to say, again this is not a perfect solution but a workaround :D
-
Re: Binding 2 QML pages
Thanks, I've found another way
1. In Main Window, I define a importer item, based on Importer.qml
2. Importer.qml has a filename property, and an importFile function
3. My B.qml (the filebrowser) calls importer.importFile
4. in A.qml, I get the filename in importer.filename
I don't need to use any global function, that way :)