On Mon, 3 Nov 2025 at 17:52, Ville Voutilainen
<[email protected]> wrote:
> > the workaround is the rather ugly:
> >
> > parent.createChild<QObject>(&parent);
>
> That's not needed at all.

See, the reason is that QObject parents aren't of type
SomeTypeInheritingQObject. They are QObjects.

That's why we don't need to deduce the parent type (which we can do
since C++23, but we don't need to go to that here),
and QObject works for the parent type.

Same goes for QWidgets.

You can of course pass whatever derived type pointer as the parent
argument, it will just get implicitly converted to a pointer
to the base type.
-- 
Development mailing list
[email protected]
https://lists.qt-project.org/listinfo/development

Reply via email to