To keep the UAV in the air in QLOITER mode after performing a takeoff in Auto mode using SITL

After performing takeoff using SITL, when I switch the UAV to QLOITER or QHOVER mode, it starts descending in Mission Planner. How can I test that the UAV maintains its altitude and position after switching to QLOITER mode, for example, at a height of 15 meters, using SITL?

Do you have something configured as a Joystick with Mission Planner on your computer? Joystick/Gamepad — Copter documentation

You can use most transmitters that have a USB port / are compatible with simulators for this as well. For example, I use my TBS Mambo configured as a joystick with Mission Planner when I use SITL simulations for some testing.