[Top][All Lists]

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

[Libqtlua-list] Question regarding accessing

From: John Boocher
Subject: [Libqtlua-list] Question regarding accessing
Date: Fri, 10 Aug 2012 09:36:21 -0400



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 slots:


    QString testFunc()


        return "testFunc called";




    static class Fcn : public QtLua::Function


      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 );


          QString retVal = controller->testFunc();

          return QtLua::Value(ls, retVal);


    } fcn;



    _state["dialog2"] = QtLua::Value(_state, new QDialog(), true);

    _state["test"] = QTLUA_REFNEW(TestController);



In lua I make the following function call: “fcn(test, dialog2)”. The TestController instance comes through fine, and I can get the second argument as a UserData::ptr, but I can’t seem to figure out how to get the second argument as the QDialog instance.


Any help would be greatly appreciated!





reply via email to

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