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

Is it possible to determine caller of event Component.onCompleted without "id" ?



  • Hi. Is it possible to determine component who called event Component.onCompleted but without "id" property ?

    Simple example:

    ListModel {
       Component.onCompleted: {
          for (var i = 0; i < 50; ++i) 
             append({ "modelData": i }); // how to call it for ListModel but without definition of "id" property directly?
       }
    }
    

    For example, C# usually have argument "object sender" in event arguments, which contains reference to object-caller.

    Thanks!


  • Qt Champions 2018

    You just did. Your code works as posted.

    What's inside Component.onCompleted has the same scope than ListModel.


  • Qt Champions 2018

    You just did. Your code works as posted.

    What's inside Component.onCompleted has the same scope than ListModel.



  • @GrecKo Well, it's so funny, You are right:-D
    I've got error, but seems like in other place. Now it works

    My mistake

    Thanks!


Log in to reply