mirror of
https://gitlab.com/Syping/luaengineapp.git
synced 2024-12-22 11:55:29 +01:00
widget code improvement
This commit is contained in:
parent
3e88d70c23
commit
ec4fb13212
2 changed files with 30 additions and 1 deletions
|
@ -60,7 +60,9 @@ void LuaEngineGui::pushClass(lua_State *L_p)
|
|||
pushFunction(L_p, "executeWidget", executeWidget);
|
||||
pushFunction(L_p, "showWidget", showWidget);
|
||||
pushFunction(L_p, "getWidgetText", getWidgetText);
|
||||
pushFunction(L_p, "setWidgetFixedSize", setWidgetFixedSize);
|
||||
pushFunction(L_p, "setWidgetLayout", setWidgetLayout);
|
||||
pushFunction(L_p, "setWidgetText", setWidgetText);
|
||||
pushVariant(L_p, "ShowCurrent", 0);
|
||||
pushVariant(L_p, "ShowNormal", 1);
|
||||
pushVariant(L_p, "ShowMinimised", 2);
|
||||
|
@ -286,6 +288,28 @@ int LuaEngineGui::setWidgetLayout(lua_State *L_p)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int LuaEngineGui::setWidgetText(lua_State *L_p)
|
||||
{
|
||||
if (getArgumentCount(L_p) >= 2) {
|
||||
void *pointer = getPointer(L_p, 1);
|
||||
if (pointer != NULL) {
|
||||
if (((QObject*)pointer)->inherits("QCheckBox")) {
|
||||
((QCheckBox*)pointer)->setText(getVariant(L_p, 2).toString());
|
||||
}
|
||||
else if (((QObject*)pointer)->inherits("QLabel")) {
|
||||
((QLabel*)pointer)->setText(getVariant(L_p, 2).toString());
|
||||
}
|
||||
else if (((QObject*)pointer)->inherits("QLineEdit")) {
|
||||
((QLineEdit*)pointer)->setText(getVariant(L_p, 2).toString());
|
||||
}
|
||||
else if (((QObject*)pointer)->inherits("QWidget")) {
|
||||
((QWidget*)pointer)->setWindowTitle(getVariant(L_p, 2).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LuaEngineGui::layoutAddLayout(lua_State *L_p)
|
||||
{
|
||||
if (getArgumentCount(L_p) >= 2) {
|
||||
|
@ -602,7 +626,11 @@ int LuaEngineGui::getWidgetText(lua_State *L_p)
|
|||
if (getArgumentCount(L_p) >= 1) {
|
||||
void *pointer = getPointer(L_p, 1);
|
||||
if (pointer != NULL) {
|
||||
if (((QObject*)pointer)->inherits("QLabel")) {
|
||||
if (((QObject*)pointer)->inherits("QCheckBox")) {
|
||||
pushVariant(L_p, ((QCheckBox*)pointer)->text());
|
||||
return 1;
|
||||
}
|
||||
else if (((QObject*)pointer)->inherits("QLabel")) {
|
||||
pushVariant(L_p, ((QLabel*)pointer)->text());
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ public:
|
|||
static int showWidget(lua_State *L_p);
|
||||
static int setWidgetFixedSize(lua_State *L_p);
|
||||
static int setWidgetLayout(lua_State *L_p);
|
||||
static int setWidgetText(lua_State *L_p);
|
||||
static int layoutAddLayout(lua_State *L_p);
|
||||
static int layoutAddWidget(lua_State *L_p);
|
||||
static int createCentralWidget(lua_State *L_p);
|
||||
|
|
Loading…
Reference in a new issue