Ben Shaw wrote:
> Dear Qt,
>
> Im attempting to port from a snapshot (4.4.0-snapshot-20071010) to the beta
> version of 4.4. Part of my code is to create a QScriptValue that wraps a
> native (c++) function, the code im using to do this is shown bellow
>
> engine_->globalObject().setProperty("ReadFile",engine_->newFunction(ScriptFu
> nctionLibrary::ReadFile),
>                                        QScriptValue::PropertyGetter |
> QScriptValue::PropertySetter); 
>
> This works fine using the snapshot but not using the beta release, instead I
> get the error 
>
> uncaught exception: TypeError: ReadFile is not a function
> 4       values = ReadFile(fileName);
>
> Your help is appreciated.
> Regards,
>
> Ben Shaw
>   

Hi,
The new behavior is correct. You define the property to be a
getter/setter, which means you can do

var a = ReadFile; // this will call your function
ReadFile = 123; // this will call your function with argument 123

The statement

ReadFile();

will call your property getter, then attempt to call the result of that
call. If your property getter itself doesn't return a function, the
latter call will fail.

Judging from your code snippets it seems you actually want ReadFile to
behave like an ordinary function, not like a property getter/setter. So
just remove the QScriptValue::PropertyGetter |
QScriptValue::PropertySetter argument.

Regards,
Kent

To unsubscribe - send "unsubscribe" in the subject to [EMAIL PROTECTED]

Reply via email to