Hi trolls,
I'm trying to make a QPoint newable and modifyable from QtScript.
I've defined the "QPoint ctor" and "QPoint::setX" function in my script.
The QPoint constructs properly, but I can't seem to find the proper
implementation for setX(int x);
inline QScriptValue QPoint_setX(QScriptContext *ctx, QScriptEngine *eng)
{
QPoint object
= ctx
->thisObject
().
toVariant().
toPoint();
if (ctx->argumentCount() == 1 && ctx->argument(0).isNumber())
{
object.setX(ctx->argument(0).toInt32());
// This doesn't seem to apply changes
ctx->setThisObject(eng->newVariant(object));
}
return eng->undefinedValue();
}
inline QScriptValue QPoint_setX(QScriptContext *ctx, QScriptEngine *eng)
{
QPoint object = ctx->thisObject().toVariant().toPoint();
if (ctx->argumentCount() == 1 && ctx->argument(0).isNumber())
{
object.setX(ctx->argument(0).toInt32());
// This doesn't seem to apply changes
ctx->setThisObject(eng->newVariant(object));
}
return eng->undefinedValue();
}
To copy to clipboard, switch view to plain text mode
Is it possible to do such a thing ?
Bookmarks