Qt.ApplicationModal will prevent the user to interact with other windows but does not interrupt any running process.
Even if you use a WorkerScript it will be difficult to have such a behavior, and if you don't your dialog will probably appear after the script is finished.
The only simple way I can think of is to cut your code in several parts, call for your dialog visibility and trigger the next step when the visible property of your dialog changes back to false.