Stress effects in ferroelectric thin films