Whether it's even well-formed depends on the low-level details of how you define syntax.
But even if it is well-formed in the syntax you use, using a variable $x$ as a dummy variable in a context where $x$ already has meaning is usually a bad idea.
That said, typically in syntax that allows such a thing, a variable acquires the innermost meaning. Therefore
$$\exists x ( Q x \to \forall x Qx)$$
is the same expression as
$$\exists x ( Q x \to \forall y Qy)$$
and is a different expression than
$$\exists x ( Q x \to \forall y Qx)$$