Alias of Alias



  • I have a ListView inside a component, let call this comp1. comp1 is used in another separate component, comp2. comp2 is again inside a separate Window, window1. Now, when I use window1, I want to assign the model of my ListView, from outside of window1. I was using alias referencing another alias throughout this multiple level of nesting, but I got an error "Invalid alias location". After look around, the document of Qt clearly state "Likewise, aliasing an aliasing property will also result in an error."

    So how do I solve this problem?

    Note: I can get away with this using alias reference entire ListView. The app run fine with expected behaviors, even the QML editor give error say the comp2 "does not have members" (it could be another unrelated error)

    Thanks



  • OK, it was the end of the day last night, so I may have made some mistake. This morning, I wonder why I can still make aliases of alias of the ListView... so I rewrite the code again, and I don't get the "Invalid alias location" anymore with the aliases of alias of the ListView's model, but now the model I assign to my model alias at the window1 seem have effect (the ListView shows nothing).

    The aliases to alias of ListView still work fine; however, I am uncomfortable with expose entire ListView, especially through multitple level...

    So any suggestion?



  • I rename the aliases and it all working now!! Duh!



  • Hi @TonyN i'm encountering the same error also. In my case, i am aliasing the text property. In component1, i have a Loader which loads the textfield, in sourceComponent I used alias for the text property (property alias text: textField.text), then use another alias to expose it outside of component1 (property alias txt: loader.item.text). When I use the component1 into a qml page, i encountered this "Invalid alias location."

    Please advice. Thanks

    EDIT: I resolved this issue using loader item alias in component1 (property alias loderItem: loader.item)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.