In 1974, Carlitz and Scoville introduced the Stirling–Eulerian polynomial \(A_n(x,y|\alpha ,\beta )\) as the enumerator of permutations by descents, ascents, left-to-right maxima and right-to-left maxima. Recently, Ji considered a refinement of \(A_n(x,y|\alpha ,\beta )\) , denoted \(P_n(u_1,u_2,u_3,u_4|\alpha ,\beta )\) , which is the enumerator of permutations by valleys, peaks, double ascents, double descents, left-to-right maxima and right-to-left maxima. Using Chen’s context-free grammar calculus, Ji proved a formula for the generating function of \(P_n(u_1,u_2,u_3,u_4|\alpha ,\beta )\) , generalizing the work of Carlitz and Scoville. Ji’s formula has many nice consequences, one of which is an intriguing \(\gamma \) -positivity expansion for \(A_n(x,y|\alpha ,\beta )\) . In this paper, we prove a q-analog of Ji’s formula by using Gessel’s q-compositional formula and provide a combinatorial approach to her \(\gamma \) -positivity expansion of \(A_n(x,y|\alpha ,\beta )\) .