[Qt-interest] Problem about QScript
Xiaolei Shang
xiaolei.shang at cobham.com
Mon Dec 13 12:38:20 CET 2010
Hi Zhongmiao:
I don't use Java, so I am not 100% sure my feeling is correct. However,
with the common sense of programming languages, I am thinking you should
check if you pass valid parameters to the function newQObject(...) in
Java codes.
What you have checked here is whether "tmp" is an object and whether
"tmp" has been defined or not. As "tmp" is just defined before the
checking, of couse it is an object and has been defined. But it does not
mean that "tmp" is a valid object. It could be an empty object because
newQObject(...) does not return valid values. So I would like to suggest
to do debugging your your Java code to make sure the function
newQObject(...) returns valid value.
Also, I just checked the qtDocmument to see the definition of
newQObject(). There are only two overloaded functions. One takes parameter
newQObject ( QObject <qobject.html> * /object/, ValueOwnership
<qscriptengine.html#ValueOwnership-enum> /ownership/ =
QtOwnership, const QObjectWrapOptions
<qscriptengine.html#QObjectWrapOption-enum> & /options/ = 0 )
The other one is:
newQObject ( const QScriptValue <qscriptvalue.html> &
/scriptObject/, QObject <qobject.html> * /qtObject/,
ValueOwnership <qscriptengine.html#ValueOwnership-enum>
/ownership/ = QtOwnership, const QObjectWrapOptions
<qscriptengine.html#QObjectWrapOption-enum> & /options/ = 0 )
I can't see your current parameters match any one of above functions.
Xiaolei
> Thank you! In fact I'm writing in QtJambi and I have turned to
> QtJambi mailing list, but they are not familiar with QScript.
> My code is as following:
>
> QScriptValue tmp=engine.newQObject(object,
> QScriptEngine.ValueOwnership.QtOwnership,
>
> QScriptEngine.QObjectWrapOption.PreferExistingWrapperObject,
>
> QScriptEngine.QObjectWrapOption.ExcludeSuperClassContents);
>
> boolean isObj= tmp.isObject();
> boolean isUNDefined=tmp.isUndefined();
> return tmp;
>
> I have checked isObj, it's true; and I also checked isUNDefined,
> it's false.
>
> So do you know if there is some other possibility that causes this
> problem? Thanks very much!
>
>
>
> On Mon, Dec 13, 2010 at 1:16 AM, Xiaolei Shang
> <xiaolei.shang at cobham.com <mailto:xiaolei.shang at cobham.com>> wrote:
>
> Hi:
>> Hi everyone,
>> is someone familiar with QScript?
>> And do you know what usually causes the following error meesage?
>>
>> TypeError: Result of expression 'canvas' [undefined] is not an
>> object.
>>
>> My code is
>>
>> var canvas = document.getElementById('tutorial');
>> var ctx = canvas.getContext('2d');
>>
>> The error is throwed in the second line. But I have checked
>> IsObject(), the value is True, IsUndefined(), the value is False.
>> Thanks a lot !
> It looks like that the function getElementById() doesnot return an
> invalid value. You'd better check the C++ definition of
> getElementById() to see if there is valid value returned.
>
> Cheers
>
> Xiaolei
>>
>> --
>> Best regards
>> Li Zhongmiao
>> Digital Media, College of Computer Science, Zhejiang University
>>
>>
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at trolltech.com <mailto:Qt-interest at trolltech.com>
>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com <mailto:Qt-interest at trolltech.com>
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
>
>
> --
> Best regards
> Li Zhongmiao
> Digital Media, College of Computer Science, Zhejiang University
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101213/b90cc6e5/attachment.html
More information about the Qt-interest-old
mailing list