diff --git a/src/plugins/lua/bindings/gui.cpp b/src/plugins/lua/bindings/gui.cpp index aaba86f461c..d34848ebc2f 100644 --- a/src/plugins/lua/bindings/gui.cpp +++ b/src/plugins/lua/bindings/gui.cpp @@ -93,10 +93,21 @@ HAS_MEM_FUNC(onClicked, hasOnClicked); HAS_MEM_FUNC(setText, hasSetText); HAS_MEM_FUNC(setTitle, hasSetTitle); HAS_MEM_FUNC(setValue, hasSetValue); +HAS_MEM_FUNC(setSize, hasSetSize); template void setProperties(std::unique_ptr &item, const sol::table &children, QObject *guard) { + if constexpr (hasSetSize::value) { + sol::optional size = children.get>("size"); + if (size) { + if (size->size() == 2) + item->setSize(size->get(1), size->get(2)); + else + throw sol::error("size must have exactly two elements"); + } + } + if constexpr (hasOnTextChanged::value) { sol::optional onTextChanged = children.get>("onTextChanged"); @@ -233,8 +244,7 @@ void addGuiModule() gui.new_usertype("Space", sol::call_constructor, sol::constructors()); - gui.new_usertype( - "Stretch", sol::call_constructor, sol::constructors()); + gui.new_usertype("Stretch", sol::call_constructor, sol::constructors()); // Layouts gui.new_usertype( @@ -306,8 +316,6 @@ void addGuiModule() }), "show", &Widget::show, - "setSize", - &Widget::setSize, sol::base_classes, sol::bases());