Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved in qt6 QJSValue call not work properly

    Qt 6
    qjsvalue qml qt6
    1
    1
    164
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      Andryski last edited by

      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

      1 Reply Last reply Reply Quote 0
      • First post
        Last post