Why Qt does not use smart pointers?
-
Well, Qt does use smart pointers such as "QScopedPointer":http://qt-project.org/doc/qt-5.0/qtcore/qscopedpointer.html
"QSharedPointer":http://qt-project.org/doc/qt-5.0/qtcore/qsharedpointer.html and "QWeakPointer":http://qt-project.org/doc/qt-5.0/qtcore/qweakpointer.html[edit, typing errors corrected, koahnig]
-
OK, sorry, I understood your question differently.
There has been a similar discussion lately here on devnet, but i do not know how to find.
For sure I cannot answer this question satisfactorily. AFAIK the overall design concept is different. That has been good enough for me so far :) -
do you actually miss it?
I think it works well without them also. And using smart pointers for all pointers would also come with extra cost of operating penalty. -
Hi,
Why Qt doesn't use smart pointers? Because it doesn't need to. Smart pointers are useful for shared objects, or to ensure destruction. Because a QObject (or an item in a view) can have only one parent, there is no sharing. For the same reason, the destruction can be done by the parent without using "complex" tools like smart pointers.
Just by curiosity, why are you asking?