We consider the stability of solutions for a family of Dirichlet problems with (p, q)-growth conditions. We apply the results obtained to show continuous dependence on a functional parameter and the existence of an optimal solution in a control problem with state constraints governed by the p(x)-Laplacian equation.