K
K
Kostyan Kondr2016-09-28 19:45:58
JavaScript
Kostyan Kondr, 2016-09-28 19:45:58

Is it possible to inject qjsonobject into a browser?

I am using qtwebkit and trying to add some json object to the page. I suspect that this can be done through evaluateJavaScript. Maybe there is another possibility?
And how to return a js object from a function that is injected through addToJavaScriptWindowObject?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kostyan Kondr, 2016-10-06
@kondr1

Solved the problem like this:

void InjectJson(QString name, QJsonObject obj){
   QJsonDocument doc(obj);
   QString json(doc.toJson());
   mainFrame()->evaluateJavaScript("var " + name + " = " + json);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question