The weights in the Q and A convolution layers are learned by means of the backpropagation algorithm on the training Q/A pairs.
obviously, classifying a new Q/A pair is partially equivalent to performing the implicit cross-pair Qto-Q and A-to-A comparison.