[Development] Another method of registering QML types

Thiago Macieira thiago.macieira at intel.com
Thu Nov 8 23:19:46 CET 2012


On quinta-feira, 8 de novembro de 2012 09.57.05, Alan Alpert wrote:
> qmlRegisterType(const char* url, const char *uri, int versionMajor,
> int versionMinor, const char *qmlName).
[...]

> This would allow for a platform component import which looks like this:
> if(platform=="desktoplinux")
>     qmlRegisterType("/usr/share/desktop/components/Button.qml", uri,
> 2, 0, "Button");
> else if (platform=="meego")
>     qmlRegisterType("/usr/share/meego/components/Button.qml", uri, 2,
> 0, "Button");

Please be careful with your uses of URL. You named the parameter "url" but 
then you passed what looks like a path name. It's definitely not an absolute 
URL, but it could be a relative one.

If the API accepts a relative URL, you need to define what it's relative to. 
For example, it's relative to the $PWD at the time of the invocation of the 
function. Or, another suggestion, is that it's relative to $PWD at the moment 
of use.

My recommendation is that you do not allow relative URLs. Require them to be 
absolute, in which case you'll need the "file:///" prefix.
-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20121108/395a5f92/attachment.sig>


More information about the Development mailing list