mirror of
https://gitlab.com/Syping/luaengineapp.git
synced 2024-12-22 11:55:29 +01:00
added getWindow
This commit is contained in:
parent
208c53aaa0
commit
1ce6cf9059
3 changed files with 35 additions and 1 deletions
|
@ -129,5 +129,5 @@ end
|
|||
|
||||
function closeDialog(pushButton)
|
||||
disconnect(pushButton, "clicked()")
|
||||
closeWidget(getParent(pushButton))
|
||||
closeWidget(getWindow(pushButton))
|
||||
end
|
||||
|
|
|
@ -131,6 +131,9 @@ void LuaEngineGui::pushClass(lua_State *L_p)
|
|||
pushVariant(L_p, "SizePolicyPreferred", (int)QSizePolicy::Preferred);
|
||||
pushVariant(L_p, "SizePolicyExpanding", (int)QSizePolicy::Expanding);
|
||||
pushVariant(L_p, "SizePolicyIgnored", (int)QSizePolicy::Ignored);
|
||||
|
||||
// Object
|
||||
pushFunction(L_p, "getWindow", getWindow);
|
||||
}
|
||||
|
||||
void LuaEngineGui::pushClass(LuaEngine *luaEngine)
|
||||
|
@ -796,6 +799,36 @@ int LuaEngineGui::createTextEdit(lua_State *L_p)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int LuaEngineGui::getWindow(lua_State *L_p)
|
||||
{
|
||||
if (getArgumentCount(L_p) >= 1) {
|
||||
void *pointer = getPointer(L_p, 1);
|
||||
if (pointer != NULL) {
|
||||
bool isWindow = false;
|
||||
QObject *object = ((QObject*)pointer);
|
||||
while (!isWindow) {
|
||||
if (object->inherits("QDialog") || object->inherits("QMainWindow")) {
|
||||
isWindow = true;
|
||||
}
|
||||
else {
|
||||
QObject *parent = object->parent();
|
||||
if (parent != NULL) {
|
||||
object = parent;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isWindow) {
|
||||
pushPointer(L_p, object);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LuaEngineGui::getWidgetText(lua_State *L_p)
|
||||
{
|
||||
if (getArgumentCount(L_p) >= 1) {
|
||||
|
|
|
@ -59,6 +59,7 @@ public:
|
|||
static int createSpacerItem(lua_State *L_p);
|
||||
static int createTextEdit(lua_State *L_p);
|
||||
static int getWidgetText(lua_State *L_p);
|
||||
static int getWindow(lua_State *L_p);
|
||||
|
||||
private:
|
||||
lua_State *L;
|
||||
|
|
Loading…
Reference in a new issue