Let $\alpha>0$ and $p\in[1,\infty)$ satisfy $\alpha p\leq n$. Suppose that $f:\rn\to\rn$ is a $K$-quasiconformal mapping and let $u\in W^{\alpha,p}(\rn)$ have compact support.
We find an optimal value of $\beta=\beta(\alpha,K,n)$ such that $u\circ f\in W^{\beta,p}(\rn)$. We also give an answer to the analogous problem where we moreover assume that $u$ is bounded.