Quaternion problem

I'm trying to get an object to rotate with mouse but only in the Z axis. The Quaternion gives me four outputs but I want to convert it so I only get the rotation on the Z-axis. I found equations that can convert it back to axis-angle but not sure how to set it so the rotation only stays in the Z-axis. Should I try other approach?

Quaternion rot = Quaternion.FromToRotation (a, b);

Have a look at the documentation for Quaternion.eulerAngles(). This method allows to specify three angles relative to the X-, Y-, and Z-axis.