add readOnly

This commit is contained in:
Syping 2019-09-25 15:56:30 +02:00
parent a37b496674
commit a22f961ac8
2 changed files with 26 additions and 0 deletions

View file

@ -78,6 +78,7 @@ void LuaEngineGui::pushClass(lua_State *L_p)
pushFunction(L_p, "setWidgetFixed", setWidgetFixed);
pushFunction(L_p, "setWidgetLayout", setWidgetLayout);
pushFunction(L_p, "setWidgetText", setWidgetText);
pushFunction(L_p, "setWidgetReadOnly", setWidgetReadOnly);
pushFunction(L_p, "setWidgetSize", setWidgetSize);
pushVariant(L_p, "ShowCurrent", 0);
pushVariant(L_p, "ShowNormal", 1);
@ -410,6 +411,30 @@ int LuaEngineGui::setWidgetEnabled(lua_State *L_p)
return 0;
}
int LuaEngineGui::setWidgetReadOnly(lua_State *L_p)
{
if (getArgumentCount(L_p) >= 1) {
void *pointer = getPointer(L_p, 1);
if (pointer != NULL) {
bool isReadOnly = true;
if (getArgumentCount(L_p) >= 2) {
isReadOnly = getVariant(L_p, 2).toBool();
}
if (((QObject*)pointer)->inherits("QPlainTextEdit")) {
((QPlainTextEdit*)pointer)->setReadOnly(isReadOnly);
}
else if (((QObject*)pointer)->inherits("QTextEdit")) {
((QTextEdit*)pointer)->setReadOnly(isReadOnly);
}
else if (((QObject*)pointer)->inherits("QLineEdit")) {
((QLineEdit*)pointer)->setReadOnly(isReadOnly);
}
return 0;
}
}
return 0;
}
int LuaEngineGui::setWidgetFixed(lua_State *L_p)
{
if (getArgumentCount(L_p) >= 1) {

View file

@ -41,6 +41,7 @@ public:
static int setWidgetEnabled(lua_State *L_p);
static int setWidgetFixed(lua_State *L_p);
static int setWidgetLayout(lua_State *L_p);
static int setWidgetReadOnly(lua_State *L_p);
static int setWidgetSize(lua_State *L_p);
static int setWidgetText(lua_State *L_p);
static int layoutAddLayout(lua_State *L_p);