Follow the dynamicCast/dynamic_pointer_cast implementation for
objectCast/object_pointer_cast since a qobject_cast can fail
just like a dynamic dast.
Also see: https://eel.is/c++draft/util.smartptr.shared.cast#6.2
See commit this commit from 2013 for more historical context:
a094bf5a89
Pick-to: 6.7 6.5
Change-Id: I9a54af55a7a1cf106cace52e9cf3bc103ae0bd42
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 7a65abb50eb638de445e24c2746d7f90c1b89f06)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>