[Development] Setters: Clarifying the ownership

Edward Welbourne edward.welbourne at qt.io
Fri Jan 19 18:26:10 CET 2018

Jaroslaw Kobus (19 January 2018 17:09)
> "give" may be confused with "get", which is usually an accessor. I may
> also think "Am I giving (to QCoreApplication)" or "The
> QCoreApplication is giving (me)". Maybe it is just a matter of the
> other verb? Absorb, hand over, hand on, suck in, swallow...

However, we have plenty of take functions, where the caller takes
ownership from the object on which the method is called; so it makes
sense that a give function would be the caller giving ownership to the
object on wich the method is called.

Thus we'd keep child.setParent(newParent), since the child doesn't take
ownership of the parent; but QMainWindow's setCentralWidget() would
become giveCentralWidget(), matching its takeCentralWidget().  This
would save the search for its doc, to find that it does indeed take

The signature is, in any case, always sufficient to make clear that a
give()r isn't a get()ter.


More information about the Development mailing list