The file: scheme URL is ultimately converted to a file path using QUrl::toLocalFile() in the QDesktopServices code, and it is this that strips the fragment identifier (which is defined for the http scheme but not file). If you paste the same file: URL into the Windows run box you get the same result, so even if Qt did not do this, Windows would.
You could try installing your own URL handler (see QDesktopServices::setUrlHandler()) and use it to launch a browser directly. Then, for example, the URL local://path/to/file#fragment can do anything you like in response to openUrl().
Bookmarks