LibreCAD
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros
luaqobject.h
Go to the documentation of this file.
1 #pragma once
2 
3 extern "C"
4 {
5 #include "lua.h"
6 #include "lualib.h"
7 #include "lauxlib.h"
8 }
9 
10 #include <QObject>
11 #include <QMetaMethod>
12 
13 #include "lua-intf/LuaIntf/LuaIntf.h"
14 #include "lua/qtbridge.h"
19 class LuaQObject : public QObject {
20  public:
25  LuaQObject(QObject* object);
26  ~LuaQObject();
27 
34  bool connect(int signalId, LuaIntf::LuaRef slot);
35 
43  void pushArg(LuaIntf::LuaState s, int const type, void const* arg);
44 
49  std::string objectName();
55  static std::string objectName(QObject* object);
56 
62  QObject* findChild(std::string name);
69  static QObject* findChild(QObject* object, std::string name);
70 
75  bool valid();
76 
82  int qt_metacall(QMetaObject::Call c, int id, void **a);
83 
84  private:
85  QObject* _object;
86 
87  int _slotId;
88  int _signalId;
89  LuaIntf::LuaRef _slotFunction;
90 
91  bool _valid;
92 };
93 
94 DECLARE_SHORT_SHARED_PTR(LuaQObject)
int _slotId
Definition: luaqobject.h:87
bool connect(int signalId, LuaIntf::LuaRef slot)
Connect Qt slot to Lua function.
Definition: luaqobject.cpp:16
std::string objectName()
Get object name.
Definition: luaqobject.cpp:66
QObject wrapper for Lua Allow connecting Qt signals with Lua functions.
Definition: luaqobject.h:19
bool valid()
Return object validity.
Definition: luaqobject.cpp:152
LuaIntf::LuaRef _slotFunction
Definition: luaqobject.h:89
int _signalId
Definition: luaqobject.h:88
bool _valid
Definition: luaqobject.h:91
void pushArg(LuaIntf::LuaState s, int const type, void const *arg)
Add signal parameter.
Definition: luaqobject.cpp:94
LuaQObject(QObject *object)
Create QObject wrapper.
Definition: luaqobject.cpp:3
QObject * findChild(std::string name)
Find children by name.
Definition: luaqobject.cpp:86
QObject * _object
Definition: luaqobject.h:85
int qt_metacall(QMetaObject::Call c, int id, void **a)
Internal Qt function This function is called when a slot of this object is called. It gets the arguments and call the Lua function.
Definition: luaqobject.cpp:33