Closed LeonnardoVerol closed 7 months ago
On top of that, you can add a new property and check If the camera is available on QML, to decide whether to use the "camera overlay scanning effect" or a text message:
on SBarcodeScanner
Q_PROPERTY(bool cameraAvailable READ cameraAvailable NOTIFY cameraAvailableChanged)
bool SBarcodeScanner::cameraAvailable() const
{
return camera->isAvailable();
}
on QML
Text {
id: cameraNotAvailable
visible: barcodeScanner.cameraAvailable === false
width: parent.width
anchors.centerIn: parent
font.pointSize: 30
font.letterSpacing: 2
font.bold: true
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
text: qsTr("Camera Not Available")
}
PS: you could also do the same to retrieve the actual "errorString"
Without a camera on the Desktop, the code will try to access
settings.at(0)
but since there are no cameras, that index is invalidon
SBarcodeScanner
Easy workaround: