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

handling return parameter for a cpp method /slot in QML



  • onClicked:{

               data = cpp_cmd.cmd_do(cmdline_txt_id.text);
                console.log(data);
            }
    

    I have a slot called cpp_cmd.cmd_do() which is called when a button is pressed.
    that cpp slot has a return paramter a string. (which contains json data) .

    return type of data is QString.

    i am not able to display it and it gives an error. how would one solve this.

    I need to futher process data or rather send it to another cpp function for further processing.


  • Lifetime Qt Champion

    Hi,

    What exact error do you get ?

    Usually slots don't have return values. Q_INVOKABLE is used for that kind of method.


Log in to reply