Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Invalid alias reference
Qt 6.11 is out! See what's new in the release blog

Invalid alias reference

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 2.4k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Naveen_DN Offline
    Naveen_DN Offline
    Naveen_D
    wrote on last edited by
    #1

    Hi all,

    I trying to get alias for some image source in a qml file, but i give property alias at the beginning of an item or rectangle and run it it is giving ,
    Invalid alias reference. Unable to find id
    can anyone please guide me further why i am not able to use alias reference. Thanks

    Naveen_D

    ekkescornerE 1 Reply Last reply
    0
    • Naveen_DN Naveen_D

      Hi all,

      I trying to get alias for some image source in a qml file, but i give property alias at the beginning of an item or rectangle and run it it is giving ,
      Invalid alias reference. Unable to find id
      can anyone please guide me further why i am not able to use alias reference. Thanks

      ekkescornerE Offline
      ekkescornerE Offline
      ekkescorner
      Qt Champions 2016
      wrote on last edited by
      #2

      @Naveen_D please post some code

      ekke ... Qt Champion 2016 | 2024 ... mobile business apps

      1 Reply Last reply
      0
      • Naveen_DN Offline
        Naveen_DN Offline
        Naveen_D
        wrote on last edited by
        #3

        this is not the complete code

        Rectangle {
            id: media_main_rect1
            width: (Screen.width/2)+200
            height: (Screen.height/2)
            color: "#e9ebf8"
             property alias imgSource: play_image.source
            Image {
                id: back_img
                width: parent.width
                height: parent.height
                source: "qrc:/MainPage/hs1.jpg"
                anchors.centerIn: parent
            }
            Selectedsong{
                id:mysong
            }
            Selectedvideo{
                id:myvideo
            }
            TabView
            {
                id:tab1
                width: media_main_rect1.width
                height: media_main_rect1.height
                states: State {
                    name: "moved";
                    when: mediaplaysrcn.visible===true
                    PropertyChanges {target:tab1; x: 0; y:0}
                }
        
                transitions: Transition {
                    NumberAnimation {
                        id: animation
                        //target: loader.item
                        property: "x"
                        from:media_main_rect1.width
                        to: 0
                        duration: 900
                        easing.type: Easing.OutQuint
                    }
                }
                ///////////////////////////////////////////////
        
                style: TabViewStyle{
        
                    frameOverlap: 3
                    tab: Rectangle {
                        color: styleData.selected ? "steelblue" :"lightsteelblue"
                        border.color:  "steelblue"
                        implicitWidth: Math.max(text.width + 6, 100)
                        implicitHeight: 30
                        radius: 6
                        Text {
                            id: text
                            anchors.centerIn: parent
                            text: styleData.title
                            color: styleData.selected ? "white" : "black"
                        }
                    }
                    frame: Rectangle { color: "steelblue" }
                }
        
                Image {
                    id: tabimage
                    width: parent.width
                    height: parent.height
                    source: "qrc:/MainPage/hs1.jpg"
                }
        
        
        
                //music
                Tab{
                    id:firsttab
                    title: "MusicPlay"
                    Image {
                        id: tab1image
                        width: parent.width
                        height: parent.height
                        source: "qrc:/MainPage/bk2.jpg"
                    }
        
                    Rectangle {
                        id: music_main_rect
                        width: (Screen.width/2)+200
                        height: (Screen.height/2)
                        color: "#e9ebf8"
                        visible:true
                        property bool checkicon: true
                        property int initailposition
                        signal sliderpositionfromqml(int initailposition)
        
                        property int duration_new
                        property int position_new
                        property int someNumber
                        property string filePath1: " "
                        property int indexNumber:-1
                        property int count:mylistview.count
                        // property url fileurl
        
        
                        Image {
                            id: back_img_musicplay
                            width: parent.width
                            height: parent.height
                            source: "qrc:/MainPage/bk2.jpg"
                            anchors.centerIn: parent
                            PropertyAnimation on x { to: 100 }
                            PropertyAnimation on y { to: 100 }
        
                        }
        
                        MouseArea{
                            anchors.fill: parent
                            onClicked:
                            {
                                selectsonglistrect.visible = false
                                volumeControl.visible = true
                            }
                        }
        
        
                        Rectangle {
                            id: playlist_text_rect
                            width: parent.width/6
                            height: parent.height/12
                            color:"transparent"
        
                            anchors.top:parent.top
                            anchors.left: parent.left
                            anchors.leftMargin:-25
                            anchors.topMargin: 20
        
                            Image {
                                id: playlist_image
                                source: "qrc:/MediaPlayer/PlaylistIcon.png"
                                width: parent.width
                                height: parent.height
                                smooth: true
                                fillMode: Image.PreserveAspectFit
                                antialiasing: true
                            }
                            MouseArea{
                                id:playlistMouseArea
                                anchors.fill: parent
                                onClicked: {
        
                                    menu.popup()
        
                                }
                            }
        
                        }//end of PlayList Rectangle
        
                        Menu {
                            id: menu
        
                            style:MenuStyle{
                                frame: Rectangle{
                                    implicitWidth: music_main_rect.width/1.5
                                    implicitHeight: music_main_rect.height/1.5
                                    width:menu.availableWidth
                                    height:implicitHeight
                                    color:"#1A1A1A"
        
        
                                    border.color: "black"
                                }
                                itemDelegate.label: Label{
                                    text: styleData.text
                                    color:"white"
                                    //font:bold
                                    font.pixelSize: 15
                                }
                                separator: Rectangle {
                                    width: parent.width
                                    implicitHeight: 5
                                    color: "white"
                                }
        
                            }
                            MenuItem {
        
                                text: "Songs"
                                onTriggered:{
                                    //playlistscrn.visible=true
                                    //mediaplaysrcn.visible=false
                                    selectsonglistrect.visible=true
                                    volumeControl.visible=false
                                    //music_main_rect.enabled=false
                                }
                            }
                            MenuItem {
                                text: "Artists                 "
                                onTriggered: playlistscrn.open()
                            }
                            MenuItem {
                                text: "Albums                  "
                                //onTriggered: saveDialog.open()
                            }
                            MenuItem {
                                text: "Folders                 "
                                //onTriggered: saveDialog.open()
                            }
        
                        }//end of menu
        
                        Rectangle{
                            id:songnameLblRect
                            width: parent.width/1.5
                            height: parent.height/12
                            color:"transparent"
                            //color:"pink"
                            anchors.top:parent.top
                            anchors.left: parent.left
                            anchors.leftMargin:parent.width-700
                            anchors.topMargin: parent.height-420
                            Text{
                                id:songnameLbl
                                color:"white"
                                //x:parent.width
                                anchors.top:parent.top
                                anchors.topMargin: parent.height-28
                                anchors.centerIn: parent
                                anchors.leftMargin: parent.width-550
                                //font.bold: true
                                font.pixelSize: 18
                                text:mysong.lblstringToQml
                            }//end of lbl
        
        
                        }//end of lbl Rectangle
        
        
                        ColumnLayout{
                            id: firstcolumn
                            anchors.centerIn: parent
                            spacing: 10
                            RowLayout{
                                id: firstrowsettings
                                spacing: 50
        
        
                                Rectangle{
                                    id:prevsongRect
                                    width: music_main_rect.width/8
                                    height: music_main_rect.height/7
                                    color: "transparent"
        
                                    Image {
                                        id: prevsong_image
                                        source: "qrc:/MediaPlayer/PreviousIcon.png"
                                        width: parent.width-8
                                        height: parent.height-8
                                        smooth: true
                                        fillMode: Image.PreserveAspectFit
                                        anchors.centerIn: parent
                                    }
                                    MouseArea{
                                        id:prevsongMA
                                        anchors.fill:parent
                                        onClicked: {
                                            if(indexNumber>0){
                                                indexNumber=(shuffle_image.source=="qrc:/MediaPlayer/ShufflePressed.png")?(Math.random() * (count - 1)):(indexNumber-1);
                                                //indexNumber--;
                                                mysong.playfuntionality(folderModel.get(indexNumber,"filePath"))
                                                songnameLbl.text=folderModel.get(indexNumber,"fileName")
                                            }
                                            else{
                                                if(indexNumber==-1){
                                                    songnameLbl.text="Please select song from Playlist"}
                                                else{
                                                    if(shuffle_image.source!="qrc:/MediaPlayer/ShufflePressed.png"){
                                                        mysong.playfuntionality(folderModel.get(indexNumber,"filePath"))
                                                        songnameLbl.text=folderModel.get(indexNumber,"fileName")
                                                    }
                                                    else{
                                                        indexNumber=(Math.random() * (count - 1))
                                                        mysong.playfuntionality(folderModel.get(indexNumber,"filePath"))
                                                        songnameLbl.text=folderModel.get(indexNumber,"fileName")
                                                    }
                                                }
                                            }
        
                                        }
                                    }
                                }
        
        
                                Rectangle{
                                    id:music1Rect
                                    width: music_main_rect.width/5
                                    height: music_main_rect.height/4
                                    color: "transparent"
        //                            property alias imgSource: play_image.source
                                    Image {
                                        id: play_image
                                        source: "qrc:/MediaPlayer/PlayIcon.png"
                                        width: parent.width-10
                                        height: parent.height-10
                                        smooth: true
                                        fillMode: Image.PreserveAspectFit
                                        anchors.centerIn: parent
        
                                        MouseArea {
                                            id:music1RectMA
                                            anchors.fill: parent
                                            
                                            onClicked: {
                                                
                                                console.log("song duration",duration_new)
                                                console.log("song position",position_new)
        
                                                // if(checkicon == false)
                                                // {
                                                if(play_image.source=="qrc:/MediaPlayer/pauseIcon.png")
                                                {
                                                    mysong.pausemusic()
                                                    mysong.setVolume(vol_control.value)
                                                    play_image.source="qrc:/MediaPlayer/PlayIcon.png"
                                                }
                                                else
                                                {
                                                    if(filePath1==" ")
                                                    {
                                                        songnameLbl.text="Please select song from Playlist"
                                                    }
                                                    else{
                                                        mysong.pausemusic()
                                                        mysong.setVolume(vol_control.value)
                                                        play_image.source="qrc:/MediaPlayer/pauseIcon.png"
                                                    }
                                                }
                                                // }
                                            }
                                        }
                                    }
                                }
        
        

        Naveen_D

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved