Using first principle calculations we examine properties of (Cd,V)Te, (Cd,Cr)Te, (Hg,V)Te, and (Hg,Cr)Te relevant to the quantum anomalous Hall effect (QAHE), such as the position of V- and Cr-derived energy levels and the exchange interactions between magnetic ions. We consider CdTe and HgTe, containing 12.5% of cation-substitutional V or Cr ions in comparison to the well-known case of (Cd,Mn)Te and (Hg,Mn)Te, and examine their suitability for fabrication of ferromagnetic barriers or ferromagnetic topological quantum wells, respectively. To account for the strong correlation of transition metal electrons we employ hybrid functionals with different mixing parameters focusing on , which better reproduces the experimental band gaps in HgTe and . We find that Cr, like Mn, acts as an isoelectronic dopant but V can be an in-gap donor in CdTe and a resonant donor in HgTe, similar to the case of Fe in HgSe. From a magnetic point of view, the Cr-doped HgTe is ferromagnetic within the general gradient approximation but becomes AFM within hybrid functionals. However, (Hg,V)Te is a ferromagnet within both exchange-correlation functionals in a stark contrast to (Hg,Mn)Te for which robust antiferromagnetic coupling is found theoretically and experimentally. Furthermore, we establish that the Jahn-Teller effect is relevant for the magnetism in the case of Cr-doping. Considering lower defect concentrations in HgTe-based quantum wells compared to (Bi, layers, our results imply that HgTe quantum wells or (Cd,Hg)Te barriers containing either V or Cr show advantages over (Bi,Sb,Cr,-based QAHE systems but whether (i) ferromagnetic coupling will dominate in the Cr case and (ii) V will not introduce too many electrons to the quantum well is to be checked experimentally.