On Thu, 16 Oct 2025 at 12:44, André Somers via Development <[email protected]> wrote: > Perhaps it might be easier or better to add a make_child template method > to QObject that returns a new instance of the template type, parented to > the object you call it on? So you could do something like: > > auto button = myDialog->make_child<QPushButton>(tr("Some button"));
+1 > I think it should be possible to specialize these where needed (like in > this case, where the expected parent is actually a QWidget, not a > QObject), but I didn't try. Perhaps it would just be simpler to have a makeChildObject<>() for QObjects and makeChildWidget<>() for QWidgets. -- Development mailing list [email protected] https://lists.qt-project.org/listinfo/development
