[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: QUrl binding in QtScript
From:       "Aaron J. Seigo" <aseigo () kde ! org>
Date:       2010-06-10 16:37:02
Message-ID: 201006100937.03110.aseigo () kde ! org
[Download RAW message or body]

[Attachment #2 (multipart/signed)]


On June 9, 2010, Onur-Hayri Bakici wrote:
> 2. obviously i can not bind qUrl in the QtScriptEngine::newQObject(QUrl)
> (becaus QUrl does not have the Q_Object macro?), nevertheless, is there any
> way to do that?

QUrl (and KUrl, by extension) are not QObjects, so no, you can't do this. 
there are two (and a half ;) approaches to this:

* create the qscript object manually in the bindings (see 
kdebase/runtime/plasma/scrtipengines/javascript/simplebindings/url.cpp)

* create a QObject wrapper around a [QK]Url object and use newQObject on that 
wrapper class, and set the constructor for "Url" (or "QUrl" or "KUrl" or all 
three) to return that in your bindings

* use QScriptClass to wrap it up; it's a bit more complex but probably the 
"most correct" for many cases as it avoids various work arounds that can be 
necessary (see 
kdebase/runtime/plasma/scrtipengines/javascript/simplebindings/bytearrayclass.
[h|cpp], borrowed from Qt :)


-- 
Aaron J. Seigo
humru othro a kohnu se
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

KDE core developer sponsored by Qt Development Frameworks

["signature.asc" (application/pgp-signature)]

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic