[Development] Qt LTS & C++11 plans (CopperSpice)

Thiago Macieira thiago.macieira at intel.com
Fri Jul 3 18:46:30 CEST 2015


On Friday 03 July 2015 09:42:54 Milian Wolff wrote:
> The above statement is far to broad to leave it uncommented. First, and 
> foremost, the only place where Qt does not play nicely with smart pointers
> are  QObject-inherited classes. This is true, but at the same time not a
> big deal as its parent-child ownership model has proven itself over the
> past twenty years. I'm not saying it's better than smart pointers, just
> that it's not much different. And furthermore, Qt is so much more than
> QObject inherited classes, and your own types in an application are also
> only QObjects if really necessary. All of the rest you can put into smart
> pointers if you want to, and Qt even offers it own fair share of smart
> pointers that are being used internally and externally (i.e. for C++98
> projects).

That said, there are a couple of places where smart use of smart pointers 
could improve Qt API.

For example, a lot of I/O code takes a QIODevice*, but does not transfer 
ownership. Which means those classes often have a getter that gives you that 
QIODevice *. The problem is that there are other places that are QIODevice 
factories, like QNAM (QNetworkReply).

Is there anything that would help people know when a pointer's ownership is 
transferred instead of just the documentation? Probably std::unique_ptr.
-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Development mailing list