Changing some functionality from C to Qt