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

Connections to attached signal



  • I have some object:
    @MyWindow {
    id: mainwindow
    }@

    and want to catch it's Component.onCompleted in some other place. I do it like this:

    @Connections {
    target: mainwindow
    Component.onCompleted: console.log("got it");
    }@

    However, instead of catching onCompleted of my target object, I get onCompleted of Connections object itself.

    Please help me to understand, how can I achieve my goal to get onCompleted signal of target object?

    Thanks a lot!


  • Moderators

    Hi, and welcome to the Qt Dev Net!

    I don't know how to connect to an attached signal externally, but you could implement a custom signal in mainWindow and emit that when the window is completed.



  • Dear JKSH!

    Thanks for your advice! I did the same for now and it works.

    I develop some application framework, and it is good for me to catch this signal directly, because in other way I have to ask users to implement that custom signal.

    In my situation, we control the base object, "MyWindow". So I put that custom signal there. It looks almost same as onCompleted in MyWindow user's descendant.


Log in to reply