[Top][All Lists]

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

Re: [Libqtlua-list] Question regarding accessing

From: Alexandre Becoulet
Subject: Re: [Libqtlua-list] Question regarding accessing
Date: Fri, 10 Aug 2012 16:37:13 +0200
User-agent: KMail/4.8.4 (Linux/3.4.3-1-ARCH; KDE/4.8.4; x86_64; ; )

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]