Quaternion Filters Madgwick, Kalman, etc

Hey everyone, I've been working on a data glove for a little while now and am still confused about filter implementation. I did get a working rotations from a 9dof IMU but I' am now trying to use the UNO Rev 2 WiFi with built in LSM6DS3 but its only a 6dof. The madgwick filter I used for that sketch had a getQuaternion() method which I input my 4 Q variables and sent the data off through serial or WiFi or whatever.

Now with this new IMU only being 6DOF I'm still having a hard time wrapping my head around how people are getting the Q variables out of the filter. I'm looking at the cpp and h files in MadgwickAHRS which I can see makes quaternions but its a void method... how do you get quaternions out of a void method? I do see a method called updateIMU which only asks for the accel and gyro inputs but again, its a void method so how do I get the Q values out of it.

Same with Kalman which is supposed to be better for orientation tracking. I still haven't ever figured out how to use these libraries properly. I've done a fair bit of research on Quaternions but still way over my head on the actual math end.

Anyone care to hop in a school me lol