> On 29 Oct 2025, at 16:27, André Somers <[email protected]> wrote: > > Hi Daniel, > On 29-10-2025 12:00, Daniel Schürmann wrote: >> >> >> >> > On 29 Oct 2025, at 01:42, Ville Voutilainen <[email protected]> >> > wrote: >> > >> >> One thing to consider in this context is if/how we’d like QLayout to be part >> of this logic. When building a widget UI, QLayout is ultimately responsible >> for taking core of the correct parent/child relationships etc. Opinions vary >> on that topic, but I typically create child widgets without parent and rely >> on the layout. So, we might find out that a QLayout::makeChildWidget makes >> sense. > Maybe...? I mean, does it need it's own, given that it is a QObject already?
Fun thing is, the widgets QLayout::makeChildWidget creates would not be children of the QLayout object :) I.e. today I often write QDialog *dialog = new QDialog; QLabel *label = new QLabel(tr(“User name:”)); QLineEdit *input = new QLineEdit; QHBoxLayout *hbox = new QHBoxLayout; hbox->addWidget(label); hbox->addWidget(input); dialog->setLayout(hbox); // now label and input are children of dialog Instead I’d write QDialog *dialog = new QDialog; QHBoxLayout *hbox = new QHBoxLayout; hbox->makeChildWidget<QLabel>(tr(“User name:”)); hbox->makeChildWidget<QLineEdit>(); dialog->setLayout(hbox); But that’s something for the future, and needs more thinking wrt different layout classes (such as grid) - so let’s focus on the basics. Volker -- Development mailing list [email protected] https://lists.qt-project.org/listinfo/development
