[Development] The future of smart pointers in Qt API
vitaly.fanaskov at qt.io
Fri Jan 31 16:46:28 CET 2020
Well, I think there are at least two cases.
1) Objects managed by smart pointers not necessary to be QObjects. In
this case, everything is clear. We can use smart pointers without any
2) Current implementation of parent-child relationships. Daniel's patch
mentioned earlier in this thread is an example of how we can use smart
pointers with current parent-child model.
My personal opinion regarding 2, that it should be just properly
implemented with using smart pointers. However, it will be tough for
existing code bases to adopt it.
On 1/31/20 4:23 PM, Matthew Woehlke wrote:
> On 31/01/2020 05.07, Vitaly Fanaskov wrote:
>> We’ve been discussing for a while how Qt6 API can be improved with using
>> smart pointers. Recently we came into some conclusions and want to
>> discuss them with the community.
>> Smart pointers are for sure much better to use than raw pointers for
>> many reasons. They manage lifetime automatically, show ownership
>> semantic, and make code safer.
> QObject already has these features since forever. How do you plan for
> this to interact with existing lifetime and ownership management via
Senior Software Engineer
The Qt Company / Qt Quick and Widgets Team
More information about the Development