For sake of completeness here is the answer from Qt developers (in case someone reads this and has the same issue):
http://lists.qt-project.org/pipermail/development/2018-April/032630.html
Unfortunately the reason why it was done in that way is still a mystery but it seems that the hook code can be safely removed