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

in qt6 QJSValue call not work properly



  • Hi!
    I'm trying to port the code from qt5._
    i have code

    void JSModule::Event(std::string name, std::string data) {
    
    	if (EventFunc.isCallable()) {
    		QJSValueList args;
    		args << QJSValue(QString::fromStdString(name)) << QJSValue(QString::fromStdString(data));
    
    		QJSValue result = EventFunc.call(args);
    		if (result.isError())
    		{
    			qWarning()<< result.toString();
    		}
    	}
    }
    
    
    function Event(name, data){
    	console.Log("name=" + name);
    }
    

    writes to the console

    Could not convert argument 0 at
           Event@:54
    TypeError: Passing incompatible arguments to C++ functions from JavaScript is not allowed.
    

    help me please


Log in to reply