  We show that every Sobolev function in $W^{1,p}_{\textrm{loc}}(U)$ on a
$p$-quasiopen set $U \subset {\bf R}^n$ with a.e.-vanishing $p$-fine gradient
is a.e.-constant if and only if $U$ is $p$-quasiconnected. To prove this we use
the theory of Newtonian Sobolev spaces on metric measure spaces, and obtain the
corresponding equivalence also for complete metric spaces equipped with a
doubling measure supporting a $p$-Poincar\'e inequality. On unweighted ${\bf
R}^n$, we also obtain the corresponding result for $p$-finely open sets in
terms of $p$-fine connectedness, using a deep result by Latvala.
