05.05.2016, 13:16, "Jean-Michaël Celerier" <jeanmichael.celer...@gmail.com>: > On Thu, May 5, 2016 at 3:24 AM, Nikos Chantziaras <rea...@gmail.com> wrote: >> By now, I consider application-level code that uses 'new' or 'delete' as >> bogus and in need of fixing. > This line of thought doesn't work at all with Qt. It's just how it is done. > If you are in such dire need of guaranteeing the absence of memory problems : > > template<typename T, typename... Args> > auto make_qobject(Args&&... args, QObject* parent) // Repeat for > QGraphicsItem / Object if necessary > { > assert(parent); > return new T{std::forward<Args>(args)..., parent}; > } > > QMainWindow win; > auto safe_obj_1 = make_qobject<QListWidget> (&win); > auto safe_obj_2 = make_qobject<QGridView>(&win);
Nevertheless that won't save from memory problems when parent needs to have longer lifetime then its children -- Regards, Konstantin _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest