Is there anyway we can prevent that?
No, as already replied in your other thread asking exactly the same, which you have not referenced from this topic. But you can keep asking the same. Or, you can look through the source code, find the exact point of the leak you claim, and fix it.
Apologies, that was https://forum.qt.io/topic/152049/stackview-is-cause-of-memory-leak, you do not seem to be the same author, though they look similar.
I also notice you are using Qt 5.12. Qt Company is not going to be addressing anything in that version.