[Interest] Need argumentative help..... giving qobject copy/assignment constructor and put it in qlist/qmap

Guido Seifert wargand at gmx.de
Mon Jul 20 18:23:23 CEST 2015

The Qt documentation did it. :-) Where I am there are no bad developers. The 'do not copy QObject' was just an unfortunate lack of information. Together with 'oh no, we don't have the time for a non-trivial redesign like that' I had some convincing to do. 

The point you listed below are the obvious problems. If no threading is used, signal/slots are carefully dis- and reconnected, the qobject is not copied around, but kept in its container, one might think one can get away with it. I wonder if there is something less obvious, which makes this a bad idea.

The main reason why I wanted the re-design was that even if it works now, something like that bites sooner or later. At one time new functionality is added, no one thinks about the copy problem anymore... and suddenly extremely hard to find bugs appear. 


On Mon, 20 Jul 2015 15:53:17 +0000
Rainer Wiesenfarth <Rainer_Wiesenfarth at Trimble.com> wrote:

> From: Guido Seifert
> > Hi, just seen this in project's code. Worse, I have been told to do it
> > exactly this way in another code part.
> What about:
> - the QObject's parent? Is it set with setParent(other->parent()) or set to nullptr?
> - the QObject's thread? Is it guaranteed that it is the same thread that creates the copy?
> - the QObject's children? Who is going to own them and when are they deleted?
> - the QObject's connections? Will all copies emit the same signals, will all copies have their slots called?
> ...or just look at the Qt documentation on QObject, at http://doc.qt.io/qt-5/qobject.html#no-copy-constructor.
> Best Regards / Mit freundlichen Grüßen
> Rainer Wiesenfarth
> -- 
> Software Engineer | Trimble Geospatial
> Rotebühlstraße 81 | 70178 Stuttgart | Germany
> Office +49 711 22881 0 | Fax +49 711 22881 11
> http://www.trimble.com/geospatial/ | http://www.inpho.de/
> Trimble Germany GmbH, Am Prime Parc 11, 65479 Raunheim
> Eingetragen beim Amtsgericht Darmstadt unter HRB 83893,
> Geschäftsführer: Dr. Frank Heimberg, Hans-Jürgen Gebauer

More information about the Interest mailing list