Reconstruction of a wave function from the Q function using a phase-retrieval method in quantum-state measurements of light