My own print function in Qt Script
I dont know why, but nothing is printed to my QtScript Debugger console, does anybody know why?
Code:
QScriptValue Debug_Function(QScriptContext *ctx, QScriptEngine *)
{
for (int i = 0; i < ctx->argumentCount(); ++i)
{
if (i != 0)
QString s
= ctx
->argument
(i
).
toString();
if (ctx->state() == QScriptContext::ExceptionState)
break;
result.append(s);
}
return ctx->engine()->toScriptValue(result);
}
Code:
QScriptValue dfunc = engine.newFunction(Debug_Function);
engine.globalObject().setProperty("debug", dfunc);
Re: My own print function in Qt Script
How about this:
Code:
QScriptValue Debug_Function(QScriptContext *ctx, QScriptEngine *)
{
for (int i = 0; i < ctx->argumentCount(); ++i)
{
if (i != 0)
QString s
= ctx
->argument
(i
).
toString();
if (ctx->state() == QScriptContext::ExceptionState)
break;
result.append(s);
}
qDebug() << result;
return ctx->engine()->toScriptValue(result);
}
Re: My own print function in Qt Script
that doesn't work. I did not see the result string in the Qt Script Debugger "Debug Output" widget.
Re: My own print function in Qt Script
Well the term "debug output" is missleading, actually it does not display debug output but:
Quote:
The debug output widget shows messages generated by the print() script function. Scripts can use the special variables __FILE__ and __LINE__ to include the current location information in the messages.
So either just use print, or hack the debugger to also redirect debug output to that window.