diff --git a/src/plugins/luatests/CMakeLists.txt b/src/plugins/luatests/CMakeLists.txt index 80e03b66ca4..0bad7da433b 100644 --- a/src/plugins/luatests/CMakeLists.txt +++ b/src/plugins/luatests/CMakeLists.txt @@ -7,4 +7,5 @@ add_qtc_lua_plugin(luatests luatests/tst_aspectcontainer.lua luatests/tst_fetch.lua luatests/tst_utils.lua + luatests/guidemo.lua ) diff --git a/src/plugins/luatests/luatests/guidemo.lua b/src/plugins/luatests/luatests/guidemo.lua new file mode 100644 index 00000000000..2771529f87a --- /dev/null +++ b/src/plugins/luatests/luatests/guidemo.lua @@ -0,0 +1,23 @@ +-- Copyright (C) 2024 The Qt Company Ltd. +-- SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +local Utils = require("Utils") +local Gui = require("Gui") + +local function using(tbl) + local result = _G + for k, v in pairs(tbl) do result[k] = v end + return result +end + +local function show() + --- "using namespace Gui" + local _ENV = using(Gui) + + Widget { + size = { 400, 300 }, + Row { "Hello World!" }, + }:show() +end + +return show diff --git a/src/plugins/luatests/luatests/tests.lua b/src/plugins/luatests/luatests/tests.lua index fb246ae94de..213aff47ebf 100644 --- a/src/plugins/luatests/luatests/tests.lua +++ b/src/plugins/luatests/luatests/tests.lua @@ -64,6 +64,19 @@ local function setup() text = "Run lua tests", onTrigger = function() a.sync(runTests)() end, }) + Action.create("LuaTests.layoutDemo", { + text = "Lua Layout Demo", + onTrigger = function() + local script, err = loadfile(Utils.FilePath.fromUserInput(script_path()):parentDir():resolvePath( + "guidemo.lua"):nativePath()) + if not script then + print("Failed to load demo:", err) + return + end + + script()() + end, + }) end return { setup = setup }