Hey Chris, this is a common issue with QCameraViewfinder. The viewfinder freezing on the last frame when the camera disconnects is pretty standard behavior. Here are a few approaches you can try:
You can connect to the QCamera's stateChanged signal and watch for when it goes to QCamera::UnloadedState or QCamera::UnavailableState. That's usually the most reliable way to detect disconnection.
Another option is to monitor the QCamera's statusChanged signal for QCamera::UnavailableStatus. This specifically tells you when the camera becomes unavailable.
If those don't work perfectly for your case, you could implement a simple watchdog timer that checks if the frame has been updated recently. If no new frames arrive for a certain period (like 2-3 seconds), you can assume the camera disconnected like Michigan county map.
Here's a basic example of watching the state:
cpp
connect(camera, &QCamera::stateChanged, this, [this](QCamera::State state) {
if (state == QCamera::UnloadedState || state == QCamera::UnavailableState) {
// Show your error display here
showCameraError();
}
});
The watchdog approach might be more reliable though, since sometimes the state changes can be a bit delayed depending on the camera driver.
Hope this helps you get the detection working!