setLayoutMargins added

This commit is contained in:
Syping 2018-08-25 02:15:54 +02:00
parent b8a5843464
commit 7ae82a4e32
3 changed files with 15 additions and 1 deletions

View file

@ -25,6 +25,7 @@ function main()
mainWindow = createMainWindow()
local mainWidget = createCentralWidget(mainWindow)
local mainLayout = createLayout(VerticalLayout, mainWidget)
setLayoutMargins(mainLayout, 0, 0, 0, 0)
local menuBar = createMenuBar(mainWindow)
local menuFile = createMenu("File", menuBar)

View file

@ -84,6 +84,7 @@ void LuaEngineGui::pushClass(lua_State *L_p)
pushFunction(L_p, "createLayout", createLayout);
pushFunction(L_p, "layoutAddLayout", layoutAddLayout);
pushFunction(L_p, "layoutAddWidget", layoutAddWidget);
pushFunction(L_p, "setLayoutMargins", setLayoutMargins);
pushVariant(L_p, "HorizontalLayout", 0);
pushVariant(L_p, "VerticalLayout", 1);
@ -254,6 +255,18 @@ int LuaEngineGui::showWidget(lua_State *L_p)
return 0;
}
int LuaEngineGui::setLayoutMargins(lua_State *L_p)
{
if (getArgumentCount(L_p) >= 5) {
void *pointer = getPointer(L_p, 1);
if (pointer != NULL && ((QObject*)pointer)->inherits("QLayout")) {
((QLayout*)pointer)->setContentsMargins(getVariant(L_p, 2).toInt(), getVariant(L_p, 3).toInt(), getVariant(L_p, 4).toInt(), getVariant(L_p, 5).toInt());
return 0;
}
}
return 0;
}
int LuaEngineGui::setWidgetFixedSize(lua_State *L_p)
{
if (getArgumentCount(L_p) >= 1) {

View file

@ -34,9 +34,9 @@ public:
static int closeWidget(lua_State *L_p);
static int executeWidget(lua_State *L_p);
static int showWidget(lua_State *L_p);
static int setLayoutMargins(lua_State *L_p);
static int setWidgetFixedSize(lua_State *L_p);
static int setWidgetLayout(lua_State *L_p);
static int setWidgetMargins(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);