As indicated in the comment, you are looking for a bit specific behavior which is not quite a QFileDialog, albeit somewhat similar, admittedly.
I believe it is not possible to shrink this feature down from QFileDialog, so I would personally go for implementing my own input box with the required sanity check in the background.
The QFileDialog implementation might give some hint for such checks, but it is not vital to see the source code of it as these are relatively simple operations.
You could then provide warning and error messages with message box. That being said, it might be more beneficial for Qt 5 to consider QML for such operations.