Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to access the property from one qml file in another.



  • I have my settingsDialog.qml file and player.qml file. I have an instance with an id settingsSwitch inside my settingsDialog and i want to access the user defined property called secondSettingSet inside my player.qml file.

    Here is the code:

    settingsDialog.qml file
    psdDialog
    {
        id: psd
        property bool secondContractionSet: false
        ....
        ....
        ....
      settingsSwitch 
    {
        if(program.model)
        {
            secondSettingSet = true;
        }
      } 
    }
    

    I have my player.qml file and inside that, i want to access the property secondSettingSet . How can i do that. And using alias to the id and different ways when i tried I am unable to access the property in my player.qml file. And they have no common parents or children except the main.qml fíle. Can't i directly access the property without touching my main.qml file?



  • You could make it a C++ property. This gives you the same functionality without placing it in the main.qml file.



  • You can achieve it by making one Qml file as singleton and declare the properties you want to access it throughout the project.


Log in to reply