[Top][All Lists]

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

Re: [Libqtlua-list] Question regarding accessing

From: John Boocher
Subject: Re: [Libqtlua-list] Question regarding accessing
Date: Fri, 10 Aug 2012 10:44:33 -0400

Thanks for the quick reply!

-----Original Message-----
From: address@hidden [mailto:address@hidden On Behalf Of Alexandre Becoulet
Sent: Friday, August 10, 2012 10:37 AM
To: address@hidden
Subject: Re: [Libqtlua-list] Question regarding accessing

On Friday, August 10, 2012 09:36:21 AM John Boocher wrote:

> I have just downloaded and started analyzing QtLua and am having 
> problems figuring out how to pass QObjects into lua functions such 
> that they can be extracted and used in c++ code. Here is what I currently 
> have:
> class TestController: public QtLua::UserData {
> public:
>     QTLUA_REFTYPE(TestController);
> public slots:

The above class is not a QObject, so "slots" do not make sense here.

>       QtLua::Value::List meta_call(QtLua::State &ls, const 
> QtLua::Value::List &args) {
>           meta_call_check_args( args, 2, 0, QtLua::Value::TUserData, 
> QtLua::Value::TUserData ); TestController::ptr controller = 
> get_arg_ud<TestController>( args, 0 ); QtLua::UserData::ptr d = 
> get_arg_ud<QtLua::UserData>( args, 1 );

You can use Value::to_qobject() and Value::to_qobject_cast<QDialog>() directly 
on the args[1] Value object. If you do not use the get_arg_ud function, you 
first have to ensure enough arguments are present in the args list. You can 
either call the meta_call_check_args function properly or check args.size().


reply via email to

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