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

problem with property alias



  • Hello,

    I show you an extract of code, it will be simpler :

        ```
    

    property alias image : im.source
    image : "pics/linux.jpeg"
    Image{
    id : im
    //source : "pics/linux.jpeg"
    }

    
        the alias does not work however it should be. the problem does not come from image "pics/linux.jpeg" because I display the image when I uncommented //source : "pics/linux.jpeg" so the probleme comes from the alias
    
        do you have an idea to solve my problem ?
        thanks a lot


  • Hi @cosmoff,

    Could you please explain clearly that what you want to achieve?



  • hi @cosmoff said in problem with property alias:

    simpler

    it's actually hard to understand what you are asking exactly, please try to use topic tools 'correctly' so the code is nicely formatted and easy to read.

    //MyImage.qml   a custom qml Component 
    Rectangle{
     id: root // top level component 
     property alias img : im
      Image{
        id:im
      }
    }
    

    now lets use the MyImage Component

    // somewhere in main.qml for example

    MyImage{
       // whe can access the alias to manipulate the Image element of our MyImage Component
    
    img.source  : "pics/linux.jpeg"
    
    }
    

Log in to reply