Sun, 05 Oct 2025 19:06:34 +0200
refactor qt containers
| ui/common/container.c | file | annotate | diff | comparison | revisions | |
| ui/common/container.h | file | annotate | diff | comparison | revisions | |
| ui/common/object.c | file | annotate | diff | comparison | revisions | |
| ui/common/objs.mk | file | annotate | diff | comparison | revisions | |
| ui/gtk/container.c | file | annotate | diff | comparison | revisions | |
| ui/qt/Makefile | file | annotate | diff | comparison | revisions | |
| ui/qt/button.cpp | file | annotate | diff | comparison | revisions | |
| ui/qt/container.cpp | file | annotate | diff | comparison | revisions | |
| ui/qt/container.h | file | annotate | diff | comparison | revisions | |
| ui/qt/entry.cpp | file | annotate | diff | comparison | revisions | |
| ui/qt/label.cpp | file | annotate | diff | comparison | revisions | |
| ui/qt/list.cpp | file | annotate | diff | comparison | revisions | |
| ui/qt/qt5.pro | file | annotate | diff | comparison | revisions | |
| ui/qt/text.cpp | file | annotate | diff | comparison | revisions | |
| ui/qt/widget.cpp | file | annotate | diff | comparison | revisions |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/common/container.c Sun Oct 05 19:06:34 2025 +0200 @@ -0,0 +1,77 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2025 Olaf Wintermann. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "container.h" +#include "object.h" + +void ui_end_new(UiObject *obj) { + if(!obj->container_end) { + return; + } + UiContainerX *rm = obj->container_end; + uic_object_pop_container(obj); + ui_free(obj->ctx, rm); +} + +void ui_newline(UiObject *obj) { + UiContainerX *container = obj->container_end; + if(container) { + container->newline = TRUE; + } +} + +void uic_layout_setup_expand_fill( + UiLayout *layout, + UiBool def_hexpand, + UiBool def_vexpand, + UiBool def_hfill, + UiBool def_vfill) +{ + if(layout->fill) { + layout->hfill = TRUE; + layout->vfill = TRUE; + layout->hexpand = TRUE; + layout->vexpand = TRUE; + return; + } + + if(!layout->override_defaults) { + if(def_hexpand) { + layout->hexpand = TRUE; + } + if(def_hfill) { + layout->hfill = TRUE; + } + if(def_vexpand) { + layout->vexpand = TRUE; + } + if(def_vfill) { + layout->vfill = TRUE; + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/common/container.h Sun Oct 05 19:06:34 2025 +0200 @@ -0,0 +1,54 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2025 Olaf Wintermann. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef UIC_CONTAINER_H +#define UIC_CONTAINER_H + +#include "../ui/container.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * prepares the layout horizontal and vertical fill/expand settings + * based on fill and defaults + */ +void uic_layout_setup_expand_fill( + UiLayout *layout, + UiBool def_hexpand, + UiBool def_vexpand, + UiBool def_hfill, + UiBool def_vfill); + +#ifdef __cplusplus +} +#endif + +#endif /* UIC_CONTAINER_H */ +
--- a/ui/common/object.c Sun Oct 05 18:13:15 2025 +0200 +++ b/ui/common/object.c Sun Oct 05 19:06:34 2025 +0200 @@ -74,39 +74,6 @@ } } -void ui_end(UiObject *obj) { - if(!obj->next) { - return; - } - - UiObject *prev = NULL; - while(obj->next) { - prev = obj; - obj = obj->next; - } - - if(prev) { - // TODO: free last obj - prev->next = NULL; - } -} - -void ui_end_new(UiObject *obj) { - if(!obj->container_end) { - return; - } - UiContainerX *rm = obj->container_end; - uic_object_pop_container(obj); - ui_free(obj->ctx, rm); -} - -void ui_newline(UiObject *obj) { - UiContainerX *container = obj->container_end; - if(container) { - container->newline = TRUE; - } -} - void ui_object_ref(UiObject *obj) { obj->ref++; }
--- a/ui/common/objs.mk Sun Oct 05 18:13:15 2025 +0200 +++ b/ui/common/objs.mk Sun Oct 05 19:06:34 2025 +0200 @@ -32,6 +32,7 @@ COMMON_OBJ = context$(OBJ_EXT) COMMON_OBJ += document$(OBJ_EXT) COMMON_OBJ += object$(OBJ_EXT) +COMMON_OBJ += container$(OBJ_EXT) COMMON_OBJ += types$(OBJ_EXT) COMMON_OBJ += properties$(OBJ_EXT) COMMON_OBJ += menu$(OBJ_EXT)
--- a/ui/gtk/container.c Sun Oct 05 18:13:15 2025 +0200 +++ b/ui/gtk/container.c Sun Oct 05 19:06:34 2025 +0200 @@ -37,6 +37,7 @@ #include "../common/context.h" #include "../common/object.h" +#include "../common/container.h" #include "../ui/properties.h" @@ -71,7 +72,6 @@ #endif } -// TODO: refactoring GtkWidget* ui_subcontainer_create( UiSubContainerType type, UiObject *obj, @@ -180,41 +180,6 @@ return (UiContainerX*)ct; } -/* - * TODO: move to common - * prepares the layout horizontal and vertical fill/expand settings - * based on fill and defaults - */ -static void layout_setup_expand_fill( - UiLayout *layout, - UiBool def_hexpand, - UiBool def_vexpand, - UiBool def_hfill, - UiBool def_vfill) -{ - if(layout->fill) { - layout->hfill = TRUE; - layout->vfill = TRUE; - layout->hexpand = TRUE; - layout->vexpand = TRUE; - return; - } - - if(!layout->override_defaults) { - if(def_hexpand) { - layout->hexpand = TRUE; - } - if(def_hfill) { - layout->hfill = TRUE; - } - if(def_vexpand) { - layout->vexpand = TRUE; - } - if(def_vfill) { - layout->vfill = TRUE; - } - } -} #if GTK_MAJOR_VERSION >= 3 void ui_grid_container_add(UiContainerPrivate *ct, GtkWidget *widget, UiLayout *layout) { @@ -226,7 +191,7 @@ ct->container.newline = FALSE; } - layout_setup_expand_fill(layout, grid->def_hexpand, grid->def_vexpand, grid->def_hfill, grid->def_vfill); + uic_layout_setup_expand_fill(layout, grid->def_hexpand, grid->def_vexpand, grid->def_hfill, grid->def_vfill); if(!layout->hfill) { gtk_widget_set_halign(widget, GTK_ALIGN_START); @@ -257,7 +222,7 @@ ct->container.newline = FALSE; } - layout_setup_expand_fill(layout, grid->def_hexpand, grid->def_vexpand, grid->def_hfill, grid->def_vfill); + uic_layout_setup_expand_fill(layout, grid->def_hexpand, grid->def_vexpand, grid->def_hfill, grid->def_vfill); GtkAttachOptions xoptions = 0; GtkAttachOptions yoptions = 0;
--- a/ui/qt/Makefile Sun Oct 05 18:13:15 2025 +0200 +++ b/ui/qt/Makefile Sun Oct 05 19:06:34 2025 +0200 @@ -33,11 +33,11 @@ $(QT_MAKEFILE): qt/$(QT_PRO_FILE) $(QMAKE) -o - $< > $(QT_MAKEFILE) -$(UI_LIB): $(QT_MAKEFILE) $(OBJ) FORCE +$(UI_LIB): $(QT_MAKEFILE) $(OBJ) $(UI_LIB) FORCE $(MAKE) -f $(QT_MAKEFILE) - $(AR) $(ARFLAGS) $(UI_LIB) $(OBJ) + $(AR) $(ARFLAGS) $(OBJ) $(UI_LIB) $(OBJ) -$(UI_SHLIB): $(OBJ) +$(UI_SHLIB): $(QT_MAKEFILE) $(OBJ) $(UI_LIB_SH) FORCE $(MAKE) -f $(QT_MAKEFILE) $(CXX) -o $(UI_SHLIB) $(LDFLAGS) $(SHLIB_LDFLAGS) $(TK_LDFLAGS) $(OBJ) -L../build/lib -lucx
--- a/ui/qt/button.cpp Sun Oct 05 18:13:15 2025 +0200 +++ b/ui/qt/button.cpp Sun Oct 05 19:06:34 2025 +0200 @@ -32,7 +32,6 @@ UIWIDGET ui_button_create(UiObject* obj, UiButtonArgs *args) { UiContainerPrivate *ctn = ui_obj_container(obj); - UI_APPLY_LAYOUT(ctn->layout, args); QString str = QString::fromUtf8(args->label); QPushButton *button = new QPushButton(str); @@ -43,7 +42,8 @@ button->connect(button, SIGNAL(destroyed()), event, SLOT(destroy())); } - ctn->add(button); + UiLayout layout = UI_ARGS2LAYOUT(args); + ctn->add(button, layout); return button; } @@ -69,7 +69,6 @@ UIWIDGET ui_togglebutton_create(UiObject* obj, UiToggleArgs *args) { UiContainerPrivate *ctn = ui_obj_container(obj); - UI_APPLY_LAYOUT(ctn->layout, args); QString str = QString::fromUtf8(args->label); QPushButton *button = new QPushButton(str); @@ -98,7 +97,8 @@ i->set = ui_togglebutton_set; } - ctn->add(button); + UiLayout layout = UI_ARGS2LAYOUT(args); + ctn->add(button, layout); return button; } @@ -129,7 +129,6 @@ UIWIDGET ui_checkbox_create(UiObject* obj, UiToggleArgs *args) { UiContainerPrivate *ctn = ui_obj_container(obj); - UI_APPLY_LAYOUT(ctn->layout, args); QString str = QString::fromUtf8(args->label); QCheckBox *checkbox = new QCheckBox(str); @@ -157,7 +156,8 @@ i->set = ui_checkbox_set; } - ctn->add(checkbox); + UiLayout layout = UI_ARGS2LAYOUT(args); + ctn->add(checkbox, layout); return checkbox; } @@ -188,7 +188,6 @@ UIWIDGET ui_radiobutton_create(UiObject *obj, UiToggleArgs *args) { UiContainerPrivate *ctn = ui_obj_container(obj); - UI_APPLY_LAYOUT(ctn->layout, args); QString str = QString::fromUtf8(args->label); QRadioButton *button = new QRadioButton(str); @@ -218,7 +217,8 @@ button->connect(button, SIGNAL(clicked()), event, SLOT(slot())); button->connect(button, SIGNAL(destroyed()), event, SLOT(destroy())); - ctn->add(button); + UiLayout layout = UI_ARGS2LAYOUT(args); + ctn->add(button, layout); return button; }
--- a/ui/qt/container.cpp Sun Oct 05 18:13:15 2025 +0200 +++ b/ui/qt/container.cpp Sun Oct 05 19:06:34 2025 +0200 @@ -29,6 +29,7 @@ #include <stdio.h> #include "container.h" #include "../common/object.h" +#include "../common/container.h" #include <cx/mempool.h> @@ -47,6 +48,7 @@ container->container = ct; container->prev = NULL; container->next = NULL; + ct->container = container; cxMempoolRegister(obj->ctx->mp, ct, (cx_destructor_func)delete_container); uic_object_push_container(obj, container); } @@ -57,11 +59,9 @@ this->box = box; box->setContentsMargins(QMargins(0,0,0,0)); box->setSpacing(0); - - ui_reset_layout(layout); } -void UiBoxContainer::add(QWidget* widget) { +void UiBoxContainer::add(QWidget* widget, UiLayout& layout) { bool fill = layout.fill; if(hasStretchedWidget && fill) { fill = false; @@ -80,18 +80,17 @@ if(fill) { hasStretchedWidget = true; } - ui_reset_layout(layout); current = widget; } UIWIDGET ui_box(UiObject *obj, UiContainerArgs *args, QBoxLayout::Direction dir) { UiContainerPrivate *ctn = (UiContainerPrivate*)ui_obj_container(obj); - UI_APPLY_LAYOUT(ctn->layout, args); + UiLayout layout = UI_ARGS2LAYOUT(args); QWidget *widget = new QWidget(); QBoxLayout *box = new QBoxLayout(dir); widget->setLayout(box); - ctn->add(widget); + ctn->add(widget, layout); ui_container_add(obj, new UiBoxContainer(box)); @@ -128,71 +127,36 @@ grid->setContentsMargins(QMargins(margin, margin, margin, margin)); grid->setHorizontalSpacing(columnspacing); grid->setVerticalSpacing(rowspacing); - ui_reset_layout(layout); } -void UiGridContainer::add(QWidget* widget) { - if(layout.newline) { +void UiGridContainer::add(QWidget* widget, UiLayout& layout) { + if(container->newline) { x = 0; y++; + container->newline = false; } - bool fill = layout.fill; - bool hexpand = false; - bool vexpand = false; - bool hfill = false; - bool vfill = false; - if(!layout.override_defaults) { - if(def_hexpand) { - hexpand = true; - hfill = true; - } else if(def_hfill) { - hfill = true; - } - if(def_vexpand) { - vexpand = true; - vfill = true; - } else if(def_vfill) { - vfill = true; - } + uic_layout_setup_expand_fill(&layout, def_hexpand, def_vexpand, def_hfill, def_vfill); + + if(layout.hexpand) { + col_expanding = true; + } + if(layout.vexpand) { + row_expanding = true; } if(layout.hexpand) { - hexpand = true; - //hfill = true; - } else if(layout.hfill) { - hfill = true; + grid->setColumnStretch(x, 1); } if(layout.vexpand) { - vexpand = true; - //vfill = true; - } else if(layout.vfill) { - vfill = true; - } - if(fill) { - hfill = true; - vfill = true; - } - - if(hexpand) { - col_expanding = true; - } - if(vexpand) { - row_expanding = true; - } - - if(hexpand) { - grid->setColumnStretch(x, 1); - } - if(vexpand) { grid->setRowStretch(y, 1); } Qt::Alignment alignment = 0; - if(!hfill) { + if(!layout.hfill) { alignment = Qt::AlignLeft; } - if(!vfill) { + if(!layout.vfill) { alignment = Qt::AlignTop; } @@ -210,7 +174,6 @@ x += colspan; - ui_reset_layout(layout); current = widget; } @@ -231,12 +194,12 @@ UIWIDGET ui_grid_create(UiObject *obj, UiContainerArgs *args) { UiContainerPrivate *ctn = (UiContainerPrivate*)ui_obj_container(obj); - UI_APPLY_LAYOUT(ctn->layout, args); + UiLayout layout = UI_ARGS2LAYOUT(args); QWidget *widget = new QWidget(); QGridLayout *grid = new QGridLayout(); widget->setLayout(grid); - ctn->add(widget); + ctn->add(widget, layout); ui_container_add(obj, new UiGridContainer( grid, @@ -288,15 +251,3 @@ return 1; } - -/* - * -------------------- Layout Functions -------------------- - * - * functions for setting layout attributes for the current container - * - */ - -void ui_newline(UiObject *obj) { - UiContainerPrivate *ct = ui_obj_container(obj); - ct->layout.newline = TRUE; -}
--- a/ui/qt/container.h Sun Oct 05 18:13:15 2025 +0200 +++ b/ui/qt/container.h Sun Oct 05 19:06:34 2025 +0200 @@ -40,48 +40,13 @@ #include <QStackedWidget> #include <QSplitter> -#define UI_APPLY_LAYOUT(layout, args) \ - layout.fill = args->fill; \ - layout.hexpand = args->hexpand; \ - layout.vexpand = args->vexpand; \ - layout.hfill = args->hfill; \ - layout.vfill = args->vfill; \ - layout.override_defaults = args->override_defaults; \ - layout.colspan = args->colspan; \ - layout.rowspan = args->rowspan - -#define ui_reset_layout(layout) memset(&(layout), 0, sizeof(UiLayout)) -#define ui_lb2bool(b) ((b) == UI_LAYOUT_TRUE ? TRUE : FALSE) -#define ui_bool2lb(b) ((b) ? UI_LAYOUT_TRUE : UI_LAYOUT_FALSE) - #define ui_obj_container(obj) (UiContainerPrivate*)((UiContainerX*)obj->container_end)->container -typedef enum UiLayoutBool { - UI_LAYOUT_UNDEFINED = 0, - UI_LAYOUT_TRUE, - UI_LAYOUT_FALSE, -} UiLayoutBool; +struct UiContainerPrivate { + UIWIDGET current; + UiContainerX *container; -typedef struct UiLayout UiLayout; -struct UiLayout { - UiBool fill; - UiBool newline; - char *label; - UiBool hexpand; - UiBool vexpand; - UiBool hfill; - UiBool vfill; - UiBool override_defaults; - int width; - int colspan; - int rowspan; -}; - -struct UiContainerPrivate { - UiLayout layout; - UIWIDGET current; - - virtual void add(QWidget *widget) = 0; + virtual void add(QWidget *widget, UiLayout& layout) = 0; virtual void end() {} }; @@ -93,7 +58,7 @@ UiBoxContainer(QBoxLayout *box); - virtual void add(QWidget *widget); + virtual void add(QWidget *widget, UiLayout& layout); }; class UiGridContainer : public UiContainerPrivate { @@ -120,7 +85,7 @@ bool def_hfill, bool def_vfill); - virtual void add(QWidget *widget); + virtual void add(QWidget *widget, UiLayout& layout); virtual void end(); };
--- a/ui/qt/entry.cpp Sun Oct 05 18:13:15 2025 +0200 +++ b/ui/qt/entry.cpp Sun Oct 05 19:06:34 2025 +0200 @@ -38,7 +38,6 @@ UIWIDGET ui_spinbox_create(UiObject *obj, UiSpinBoxArgs *args) { UiContainerPrivate *ctn = ui_obj_container(obj); - UI_APPLY_LAYOUT(ctn->layout, args); double min = args->min; double max = args->max != 0 ? args->max : 100000; @@ -143,8 +142,8 @@ } } - - ctn->add(widget); + UiLayout layout = UI_ARGS2LAYOUT(args); + ctn->add(widget, layout); return widget; }
--- a/ui/qt/label.cpp Sun Oct 05 18:13:15 2025 +0200 +++ b/ui/qt/label.cpp Sun Oct 05 19:06:34 2025 +0200 @@ -34,7 +34,6 @@ UIWIDGET ui_label_create(UiObject* obj, UiLabelArgs *args) { UiContainerPrivate *ctn = ui_obj_container(obj); - UI_APPLY_LAYOUT(ctn->layout, args); QString str = QString::fromUtf8(args->label); QLabel *widget = new QLabel(str); @@ -47,7 +46,8 @@ } widget->setAlignment(align); - ctn->add(widget); + UiLayout layout = UI_ARGS2LAYOUT(args); + ctn->add(widget, layout); return widget; }
--- a/ui/qt/list.cpp Sun Oct 05 18:13:15 2025 +0200 +++ b/ui/qt/list.cpp Sun Oct 05 19:06:34 2025 +0200 @@ -48,7 +48,6 @@ UIWIDGET ui_listview_create(UiObject* obj, UiListArgs *args) { UiContainerPrivate *ctn = ui_obj_container(obj); - UI_APPLY_LAYOUT(ctn->layout, args); QListView *view = new QListView(); ui_getvaluefunc2 getvalue = nullptr; @@ -87,15 +86,14 @@ model, SLOT(selectionChanged(const QItemSelection &, const QItemSelection &))); - - ctn->add(view); + UiLayout layout = UI_ARGS2LAYOUT(args); + ctn->add(view, layout); return view; } UIWIDGET ui_table_create(UiObject* obj, UiListArgs *args) { UiContainerPrivate *ctn = ui_obj_container(obj); - UI_APPLY_LAYOUT(ctn->layout, args); QTreeView *view = new QTreeView(); view->setItemsExpandable(false); @@ -138,7 +136,8 @@ SLOT(selectionChanged(const QItemSelection &, const QItemSelection &))); - ctn->add(view); + UiLayout layout = UI_ARGS2LAYOUT(args); + ctn->add(view, layout); return view; }
--- a/ui/qt/qt5.pro Sun Oct 05 18:13:15 2025 +0200 +++ b/ui/qt/qt5.pro Sun Oct 05 19:06:34 2025 +0200 @@ -26,7 +26,7 @@ # POSSIBILITY OF SUCH DAMAGE. # -TARGET = uitk +TARGET = uitk_qt TEMPLATE = lib CONFIG += staticlib warn_off debug DESTDIR = ../build/lib
--- a/ui/qt/text.cpp Sun Oct 05 18:13:15 2025 +0200 +++ b/ui/qt/text.cpp Sun Oct 05 19:06:34 2025 +0200 @@ -59,10 +59,10 @@ UIWIDGET ui_textarea_create(UiObject *obj, UiTextAreaArgs *args) { UiContainerPrivate *ctn = ui_obj_container(obj); - UI_APPLY_LAYOUT(ctn->layout, args); QTextEdit *textarea = new QTextEdit(); - ctn->add(textarea); + UiLayout layout = UI_ARGS2LAYOUT(args); + ctn->add(textarea, layout); QTextDocument *document = nullptr; @@ -212,10 +212,10 @@ static UIWIDGET create_textfield(UiObject *obj, UiTextFieldArgs *args, bool password, bool frameless) { UiContainerPrivate *ctn = ui_obj_container(obj); - UI_APPLY_LAYOUT(ctn->layout, args); QLineEdit *textfield = new QLineEdit(); - ctn->add(textfield); + UiLayout layout = UI_ARGS2LAYOUT(args); + ctn->add(textfield, layout); if(password) { textfield->setEchoMode(QLineEdit::Password);
--- a/ui/qt/widget.cpp Sun Oct 05 18:13:15 2025 +0200 +++ b/ui/qt/widget.cpp Sun Oct 05 19:06:34 2025 +0200 @@ -34,8 +34,8 @@ UIWIDGET ui_customwidget_create(UiObject *obj, ui_createwidget_func create_widget, void *userdata, UiWidgetArgs *args) { UIWIDGET widget = create_widget(obj, args, userdata); UiContainerPrivate *ctn = ui_obj_container(obj); - UI_APPLY_LAYOUT(ctn->layout, args); - ctn->add(widget); + UiLayout layout = UI_ARGS2LAYOUT(args); + ctn->add(widget, layout); return widget; } @@ -45,9 +45,8 @@ separator->setFrameShadow(QFrame::Sunken); UiContainerPrivate *ctn = ui_obj_container(obj); - UI_APPLY_LAYOUT(ctn->layout, args); - - ctn->add(separator); + UiLayout layout = UI_ARGS2LAYOUT(args); + ctn->add(separator, layout); return separator; }