Rocksalt $\mathrm{Z}{\mathrm{n}}_{x}\mathrm{M}{\mathrm{g}}_{1\ensuremath{-}x}\mathrm{O}$ alloys are theoretically and experimentally investigated for near- and deep-UV optoelectronics with a tunable band gap of 4.2--7.8 eV. Regarding the key question about the composition $x$, at which there is a transition between the direct and indirect gaps, we performed ab initio calculations for various Zn concentrations and all possible atomic arrangements in eight- to 64-atom supercells. We show that, depending on the detailed Zn distribution (clustered, random, or uniform distribution), the alloy band gap can vary by as much as 1.27 eV. The band gap is indirect for clustered and random Zn arrangements in the supercell. For uniform Zn arrangements, the gap is also indirect, except for $x<0.5$ and atom uniform arrangements excluding Zn-O-Zn nearest neighbor bridges, for which the direct gap can be lowered below the indirect gap by about 0.1 eV. The mechanisms of band-gap fluctuation, Zn clustering, and direct-indirect band-gap transitions are analyzed and explained in terms of atomic contributions to band structures by projecting Bloch functions onto localized Wannier functions. Simultaneously, cathodoluminescence measurements were performed on a set of $\mathrm{Z}{\mathrm{n}}_{x}\mathrm{M}{\mathrm{g}}_{1\ensuremath{-}x}\mathrm{O}$ multiquantum wells grown by molecular beam epitaxy on MgO substrates. We observed strong and broad emission bands, redshifting with increasing Zn concentration but featuring no clear-cut evidence for any direct to indirect band-gap crossover. We argue that these alloys are well suited for deep-UV optoelectronics, thanks to the rare combination of strong exciton binding energy, coupling to phonons, and carrier localization, which is favored by the marked flattening of the top valence bands by both short-range and long-range Zn-Zn interactions.