Find basis for space of integer columns such that $AX=B$ I have the following problem:

Determine all the integer solutions to the system of equations $AX=0$, when $A=\left[
    \begin{matrix}
    4 & 7 & 2 \\
    2 & 4 & 6
    \end{matrix}    \right]$. Find a basis for the space of integer columns vectors $B$ such that $AX=B$.

I first diagonalize the matrix as follows and have to find $Q^{-1},P$ such that $A'=Q^{-1}AP$.
$$
\begin{gather*}
    \left[
    \begin{matrix}
    4 & 7 & 2 \\
    2 & 4 & 6
    \end{matrix}    \right]\xrightarrow{2r_2-r_1}\left[
    \begin{matrix}
    4 & 7 & 2 \\
    0 & 1 & 10
    \end{matrix}    \right]\xrightarrow{r_1-7r_2}\left[
    \begin{matrix}
    4 & 0 & -68 \\
    0 & 1 & 10
    \end{matrix}    \right]\xrightarrow{c_3+17c_1}\left[
    \begin{matrix}
    4 & 7 & 0 \\
    0 & 1 & 10
    \end{matrix}    \right]\\
    \xrightarrow{2r_2-r_1}\left[
    \begin{matrix}
    4 & 7 & 2 \\
    0 & 1 & 10
    \end{matrix}    \right]
    \xrightarrow{-c_3}\left[
    \begin{matrix}
    4 & 7 & 0 \\
    0 & 1 & -10
    \end{matrix}    \right]\xrightarrow{c_3+10c_2}\left[
    \begin{matrix}
    4 & 0 & 0 \\
    0 & 1 & 0
    \end{matrix}    \right]=A'
\end{gather*}
$$
Then we can form the matrix equivalent to applying the operations used to diagonalize the matrix.
$$
\begin{gather*}
    Q^{-1}=\left[
    \begin{matrix}
    1 & -7  \\
    0 & 1 
    \end{matrix}    \right]\left[
    \begin{matrix}
    1 & 0  \\
    -1 & 2 
    \end{matrix}    \right]=\left[
    \begin{matrix}
    8 & -14  \\
    -1 & 2 
    \end{matrix}    \right] \\
    P = \left[
    \begin{matrix}
    1 & 0 & 17  \\
    0 & 1 & 0  \\
    0 & 0 & 1 
    \end{matrix}    \right]
    \left[
    \begin{matrix}
    1 & 0 & 0  \\
    0 & 1 & 0  \\
    0 & 0 & -1 
    \end{matrix}    \right]
    \left[
    \begin{matrix}
    1 & 0 & 0  \\
    0 & 1 & 10  \\
    0 & 0 & 1 
    \end{matrix}    \right]=\left[
    \begin{matrix}
    1 & 0 & -17  \\
    0 & 1 & 10  \\
    0 & 0 & -1 
    \end{matrix}    \right]
\end{gather*}
$$
The solution to $A'X'=0$ is given by $X'=[0,0,n]$ for $n\in\mathbb{Z}$. Then, $X=PX'=[-17n,10n,-n]^t$, which after I tested a few cases, it seems to be correct. So, it seems that so far so good.
But to find the basis I need to get $Q$, but when I try to invert $Q^{-1}$, I get that $Q=\left[
    \begin{matrix}
    1 & 7  \\
    .5 & 4 
    \end{matrix}    \right]\not\in \mathbb{Z}$, so that just means my calculation of $Q^{-1}$, and possibly $P$ was incorrect. So, how can one correctly calculate $Q^{-1}$ and $P$?

You first need to swap $r_2$ with $r_1$ before you begin in order to use the algorithm listed in Artin (which I assume you are using as this is a question from the book). Look at step 1 of the proof listed. You must permute rows and columns to move a nonzero entry with smallest absolute value to the upper left corner. This could be done with column operations, but it's not as easy to compute the matrix multiplication after.
Therefore, the first elementary matrix you get, and last one you multiply to find $Q^{-1}$ is
$\pmatrix{0 & 1\\
1 & 0}
 $.
