Given that C is the centroid of the triangle, then:

This means that the length of QC is twice the length of CM.
Substituting with QC = 5x and CM = x + 12, and solving for x:

The length of QM can be expressed as follows:
QM = QC + CM
Substituting with QC = 5x and CM = x + 12
QM = 5x + x + 12
QM = 6x + 12
Substituting with x = 8:
QM = 6*8 + 12
QM = 48 + 12
QM = 60