Usually the derivative is defined for a function $f:A\to \mathbb{R}$ where $A \subset \mathbb{R}$, and the usual definition of the derivative at a point $a$ require the existence of an open neighborhood of $a$ where the function is defined.
So, if $A\subset \mathbb{Q}$ it seems that we cannot define a derivative, since $A$ is totally disconnected.
But the definition
$$ f'(a)=\lim_{h \to 0}\dfrac{f(a+h)-f(a)}{h} $$
require only the existence of the limit that, with the $\epsilon -\delta$ definition, can be found using only rational values of $h$.
So it seams that a ''derivative'' can be defined. Or there is something that does not works?
This question is suggested by Clarification if a disconnected function has a derivative at defined points. , where the OP asks for the derivability of the function $$ f:\{x=\dfrac{n}{2k+1} | n,k \in \mathbb{Z}\} \to \mathbb{R} \quad;\quad f(x)=(-2)^x $$
There's no reason that a derivative couldn't be defined on such a set like $\mathbb Q$. As you note, the limit $$\lim_{h\rightarrow 0}\frac{f(a+h)-f(h)}{h}$$ may still be calculated even if $a+h$ is restricted to only rational values.
I think it's worth noting that the fact that $\mathbb Q$ is totally disconnected might give the wrong impression. The above definition only fails when fed isolated points - that is points with no other points in the domain in an open neighborhood. In the language of topology, we could say points such that $\{x\}$ is open in the domain of the function. Whether or not the domain is connected it somewhat irrelevant. So, you can't use this definition of for a function defined only on $\mathbb Z$ where every point is isolated. But it works fine on any dense subset of $\mathbb R$, like $\mathbb Q$. Another similar thing to think about is that not all function $f:\mathbb Q\rightarrow\mathbb R$ are continuous, despite $\mathbb Q$ being totally disconnected.
We might avoid using such a derivative as one might notice that a lot of theorems (e.g. the fundamental theorem of calculus) really do need conditions like "$f:\mathbb R\rightarrow\mathbb R$ is everywhere differentiable" which can't be replaced by $f:A\rightarrow\mathbb R$ being differentiable everywhere in its domain.