libqtlua-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Libqtlua-list] Extract QObject from Lua


From: David Palacio
Subject: Re: [Libqtlua-list] Extract QObject from Lua
Date: Sat, 15 Oct 2011 00:00:11 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

On Thu, Sep 29, 2011 at 05:21:02PM -0500, David Palacio wrote:
> Hi,
> 
> I have exposed some QObjects to the Lua enviroment to let the automatic
> bindings to properties and slots do most of the work. I also want to use those
> QObjects as arguments tin Lua functions written in C++. I have found this
> difficult to get. Right now I use this on a function meta_call:
> 
> QtLua::Value val = get_arg<QtLua::Value>(args,0);
> QObjectWrapper::ptr optr = 
>     val.to_userdata_cast<QObjectWrapper>();
> Plasma::Containment *c = 
>     qobject_cast<Plasma::Containment*>(&optr.ptr()->get_object());
> 
> 1. Get a generic Value 
> 2. Cast the generic Value to a QObjectWrapper. I need the
>    QObjectWrapper internal header to do this.
> 3. Cast the qobject to the desired class.
> 
> 
> It works but, I would like to do it with the public API.
> I can not use UserData derived classes because these objects are not created 
> in
> my application but in a KDE library.
> 
> It is good to be able to wrap a QObject in a Value. I think it would be great
> to get it back with a Value::to_qobject function.
> 
> Regards,
> David.

I modified QtLua::Value to offer to_qobject and to_qobject_cast methods.
See attached patches.

Regards,

David.

Attachment: 0001-Install-headers-to-the-QtLua-prefix.patch
Description: Text Data

Attachment: 0002-add-a-to_qobject-convert-method-to-the-Value-class.patch
Description: Text Data

Attachment: 0003-add-to_qobject_cast-helper.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]