Unsolved console functions
-
@SPlatten sorry i have no experience with that then
do you mean instead of using QObject::connect() you are connecting a signal to a slot by using some js code? -
No I'm using QObject::connect:
cnSignal = QObject::connect(this ,&clsQtTextEdit::jsonTextChanged ,[pobjScriptEng, strCall, strFile, strScript](QJsonObject objJSON) { QString strJSON = clsXMLnode::strJSON(objJSON) ,strScriptWithCall = static_cast<QString>(strScript) + static_cast<QString>(strCall) + static_cast<QString>("(" + strJSON + ");"); pobjScriptEng->evaluate(strScriptWithCall); });
-
@SPlatten i have definitely no experience with that but i see this method, maybe it can help ..
QJSEngine myEngine; myEngine.installExtensions(QJSEngine::ConsoleExtension); QJSValue fun = myEngine.evaluate("(function(a, b) { console.log( a + b ) ; })"); QJSValueList args; args << 1 << 2; QJSValue threeAgain = fun.call(args);
-
console.log isn't available when using the Qt JavaScript engine, that is the function I would have used instead of console.info if it was available.
-
@SPlatten you can make it available by calling QJSEngine::installExtensions()
-
@LeLev said in console functions:
installExtensions
I already have this in my C++ engine:
clsScriptHelper::mspobjJSeng->installExtensions(QJSEngine::AllExtensions);
-
As pointed out by @LeLev , the link:
installExtensionsShows in the text that using:
QJSEngine::ConsoleExtensionShould give console.log, however I've passed:
QJSEngine::AllExtensionsAnd I do not get console.log, however console.info works.
Anyone ?
-
Hi
The docs talks about
CONFIG+=qml_debug
in .pro file.
Im not sure if its related to that. -
@mrjj, thank you, added that to pro file console.log now works. console.dir still doesn't.
-
@SPlatten said in console functions:
console.dir
Are you sure this is included?
I have not seen it mentioned in the docs. -
@mrjj , sorry I just assume that since console.log, console.info are part of the functions that are available in JavaScript when using Node.js that console.dir would also be present.
-
@SPlatten
Hi
Its a valid assumption but i cant find any reference to it- so it seems not included. -
@SPlatten
No, it is not.
You can check the available Console API.