You can solve this by adding a Container around the outer Container in the QML file and setting its background to Color.Black . Then we added the id to the previously deleted Container and implemented the onScreenEnabled(enabled) function to show or hide it.
Container { background: Color.Black Container { id: callContainer ... } } function onScreenEnabled(enabled) { callContainer.visible = enabled; }
In the .cpp file, use the proximity sensor to emit a signal to turn the screen on or off:
void CallProgress::checkReading() { bool isClose = proximitySensor->reading()->close(); this->SetScreenEnabled(!isClose); } void CallProgress::SetScreenEnabled(const bool enabled) { emit screenEnabled(enabled); }
Add signal and function declarations to the .h file. In the .qml file, connect the emitted signal to the corresponding QML function.
This will hide the user interface when the proximity sensor detects that the user is close to the screen.
source share