You cannot do that with Qt and there is no portable solution. If you want something portable, do it yourself, using platform dependent API.

I have recently done something similar at work, but unfortunately I also needed to lock files on samba shares, therefore the platform API functions were of no use ( on Mac and Win ) and I did a custom locking mechanism.

If you only need to lock local files, go ahead and use system API.
It is not necessary to have #ifdef's all over your app, just where you implement the functionality - for example the function(s) will be called the same and will take the same number of params both on Win and Linux.

Regards