Passing signal from C++ to object in loader



  • Hi everyone, I'm having some issues on passing a signal from C++ to a loader that handles the object I need to receive the signal.

    The struct is:

    -C++ Layer (emits the signal, object correctly connected to main.qml file)
    -Main.qml (main with many object and a loader)
    -Loader Obj
    -Item loaded (I need the signal to arrive here)

    I've several files that my loader will load and every file handles that signal, so I need to find a solution that could work even if I change the loaded file.

    Any suggestions?

    Thank you.



  • If I understood you correctly, you would like to dynamically load a file using the Loader component and then connect the loaded object to a signal that is emitted from the C++ layer.

    Why don't you try something like this:

    @
    Loader {
    id: loader
    onLoaded: CPPLayer.signal.connect(loader.item.slot);
    }
    @

    I have not tested this as I am unsure how your C++ layer connects to QML but hopefully this will give you some ideas.



  • Thank you.
    By now I've solved my problem adding a Connection element on the loaded component, on every sub-component of the loaded item!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.