Lua: Make Layout-derived classes directly show-able

Change-Id: I2bea8187626c239b5b2e9ddb32d291db97ddc9ac
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
hjk
2024-05-28 15:45:32 +02:00
parent a1146cbef4
commit ded8cf3fdb
4 changed files with 16 additions and 1 deletions

View File

@@ -686,6 +686,11 @@ QWidget *Layout::emerge() const
return widget; return widget;
} }
void Layout::show() const
{
return emerge()->show();
}
// "Widgets" // "Widgets"
Widget::Widget(std::initializer_list<I> ps) Widget::Widget(std::initializer_list<I> ps)

View File

@@ -156,6 +156,7 @@ public:
void fieldGrowthPolicy(int policy); void fieldGrowthPolicy(int policy);
QWidget *emerge() const; QWidget *emerge() const;
void show() const;
QFormLayout *asForm(); QFormLayout *asForm();
QGridLayout *asGrid(); QGridLayout *asGrid();

View File

@@ -99,7 +99,7 @@ SOL_BASE_CLASSES(Layouting::Row, Layouting::Layout);
SOL_BASE_CLASSES(Layouting::Flow, Layouting::Layout); SOL_BASE_CLASSES(Layouting::Flow, Layouting::Layout);
SOL_BASE_CLASSES(Layouting::Grid, Layouting::Layout); SOL_BASE_CLASSES(Layouting::Grid, Layouting::Layout);
SOL_BASE_CLASSES(Layouting::Form, Layouting::Layout); SOL_BASE_CLASSES(Layouting::Form, Layouting::Layout);
SOL_BASE_CLASSES(Layouting::Widget, Layouting::Widget); SOL_BASE_CLASSES(Layouting::Widget, Layouting::Object);
SOL_BASE_CLASSES(Layouting::Stack, Layouting::Widget); SOL_BASE_CLASSES(Layouting::Stack, Layouting::Widget);
SOL_BASE_CLASSES(Layouting::Tab, Layouting::Widget); SOL_BASE_CLASSES(Layouting::Tab, Layouting::Widget);
SOL_BASE_CLASSES(Layouting::Group, Layouting::Widget); SOL_BASE_CLASSES(Layouting::Group, Layouting::Widget);

View File

@@ -231,6 +231,15 @@ void addLayoutModule()
"Stretch", sol::call_constructor, sol::constructors<Stretch(int)>()); "Stretch", sol::call_constructor, sol::constructors<Stretch(int)>());
// Layouts // Layouts
layout.new_usertype<Layout>(
"Layout",
sol::call_constructor,
sol::factories(&construct<Layout>),
"show",
&Layout::show,
sol::base_classes,
sol::bases<Object, Thing>());
layout.new_usertype<Form>( layout.new_usertype<Form>(
"Form", "Form",
sol::call_constructor, sol::call_constructor,