libqtlua-list
[Top][All Lists]
Advanced

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

Re: [Libqtlua-list] Accessing QObject inside a property in Lua


From: Alexandre Becoulet
Subject: Re: [Libqtlua-list] Accessing QObject inside a property in Lua
Date: Wed, 12 Jan 2011 00:56:17 +0100
User-agent: KMail/1.13.5 (Linux/2.6.36-ARCH; KDE/4.5.4; x86_64; ; )

On Tuesday, January 11, 2011 03:27:53 pm Gustavo de Sá Carvalho Honorato 
wrote:

Hi,

> I'm trying to access my MainWindow class throught a property which is
> declared inside my Application class in Lua. I've declared the
> MainWindow using Q_DECLARE_METATYPE(MainWindow*) and
> qRegisterMetaType<MainWindow*>(). I've exposed my application class
> using state["app"] = QtLua::Value(state, qApp, false).
> 
> The problem occurs when I try to access the MainWindow by typing
> app.mainWindow:close() in Lua Console, and I got the error "error:
> [string ""]:1: attempt to index field 'mainWindow' (a nil value)".
> 
> It's quite weird because when I type list(app) I can see that the
> property mainWindow has a value QtLua::Property<MainWindow*>
> mainWindow = Application::mainWindow.

QtLua has no way to guess how to convert your declared meta type to a 
QtLua::Value. Try using a QObject* or QWidget* instead of a MainWindow* 
pointer type.

Lua/Qt values convertion on property access and method call is performed by 
raw_get_object and raw_set_object in src/qtluamember.cc. Supporting dynamic 
declaration of new types would require registering two callbacks to implement 
value convertion, I can implement this if there is a real need.

-- 
Alexandre




reply via email to

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