See the comment here and resulting test code that uses private API:
https://codereview.qt-project.org/c/qt/qtquickcontrols2/+/311928/2/tests/auto/shared/visualtestutil.cpp#154