Let $n > k$. Let $\textbf{Q} = \textbf{I}_n - \textbf{X}(\textbf{X}^T\textbf{X})^{-1}\textbf{X}^T$ where $\textbf{I}_n$ is an $n \times n$ identity matrix, $\textbf{X}$ is a $n \times (k+1)$ matrix with rank $k+1$ and the first column of $\textbf{X}$ contains only of $1$'s. I would like to show that $\textbf{Q}$ has rank $n-k-1$.
First note that $\textbf{Q}\textbf{X} = \boldsymbol{0}$ and $\textbf{Q}$ is an $n \times n$ matrix. Because $\textbf{Q}\textbf{X} = \boldsymbol{0}$, the rows of $\textbf{Q}$ satisfy the following $k + 1$ constraints: \begin{align*} \sum_{j=1}^nq_{ji} &= 0, \ j = 1, \dotsc, n;\\ \sum_{j=1}^nq_{ji}x_{i1} &= 0, \ j = 1, \dotsc, n;\\ &\vdots\\ \sum_{j=1}^nq_{ji}x_{ik} &= 0, \ j = 1, \dotsc, n. \end{align*}
I feel like I am almost there, but I can't seem to explain why the rank of $\textbf{Q}$ is $n-k-1$ using these constrains.