Qatar's Penal Code has clear rules about jurisdiction on vessels and aircraft. Under Article 14, Qatari criminal law applies to any offence committed onboard ships or aircraft that are registered in, owned by, or flying the flag of Qatar — regardless of where in the world the vessel or aircraft happens to be at the time of the offence. So if you are on a Qatar-registered ship or a Qatar Airways flight anywhere in the world, Qatari law applies.
For foreign vessels passing through Qatari territory, the situation is different. Article 15 states that, without prejudice to international agreements Qatar has signed, the Penal Code does not apply to offences committed onboard foreign ships or aircraft that are simply in or passing through Qatar's jurisdiction. This means that internal disputes or offences on a foreign-flagged vessel transiting Qatar may remain under the jurisdiction of the vessel's flag state.
As a practical tip for expats, if you witness or are involved in an incident on any aircraft or vessel, the applicable law will depend primarily on the vessel's registration. It is wise to report any incidents to the appropriate crew, and if in any doubt about your legal position, seek legal advice from a Qatari lawyer as soon as you arrive in Qatar.
This is general legal information, not legal advice. For advice on your specific situation, consult a lawyer licensed in Qatar.