Important: Please read the Qt Code of Conduct -

Regarding Loader

  • Hi all,
    I have two separate files notificationBar.qml and MusicPlayer.qml in my project. i am loading these files using Loader in main.qml and initially i have made the musicplayer.qml as active=false and visible= false.while loading the notificationBar.qml i am setting a label text = "AAAA". Now when i get the output everything is fine i get the label as expected. Based onClicked event i am making the musicplayer.qml as active=true and visible=true but at this point i also want to change the label which already loaded as "AAAA" how can i do this ?
    I tried to create an object of notificationBar with an id in musicplayer.qml and in onClicked event i tried to change the label but didn't get the output.

  • Hello, can anyone please guide me to solve the above issue, Thanks

  • @Naveen_D
    Sorry, I didn't get much out of your question.
    That's what I understood so far:

    • you have two files called notificationBar.qml and MusicPlayer.qml
    • you load them both in your main.qml using two different Loader components
    • you have a label with text "AAAAA"
    • you have a Button used to enable the MusicPlayer and put it visibile
    • with the same click signal on the same button you want to change the label

    The problem is that you are not able to change the label by clicking on the button?
    Or what else?
    Could you please provide us some snippet of code?

  • @Marco-Pellin Thanks for the reply.

    ya exactly when i am making the music player visible with a click event i want to change the label to some other text. but the notificationBar.qml wil be already loaded so i am not able to change the label text.

    in main.qml i am loading both :

    Loader {
            id: notificationBarLoader
            visible: true
            anchors.left: parent.left
            anchors.right: parent.right
            active: true
            source: notificationBarSource
            onLoaded: {
                  item.mainText= "Infotainment Solutions"
    Loader {
            id: musicContentLoader
            visible: false
            active: false
            source: musicplayerContentScreen

    code where i am making the musicplayer visible with click event, here i have created an object of notificationBar.qml as notification:

                            MouseArea {
                                id: musicmousearea
                                anchors.fill: parent
                                onClicked: {
                                    initialContentLoader.visible= false
                                    shortcuticonbarLoader.visible= true
                                    musicContentLoader.visible= true
    //                                notification.mainText= "Music Player"  // i tried to change the label text here but didn't work for me //

Log in to reply