159 auto maybeControl = QPlatformMediaIntegration::instance()->createCamera(q);
161 qWarning() <<
"Failed to initialize QCamera" << maybeControl.error();
164 control = maybeControl.value();
165 cameraDevice = !device.isNull() ? device : QMediaDevices::defaultVideoInput();
166 if (cameraDevice.isNull())
167 control->updateError(QCamera::CameraError, QStringLiteral(
"No camera detected"));
168 control->setCamera(cameraDevice);
169 q->connect(control, &QPlatformVideoSource::activeChanged, q, &QCamera::activeChanged);
170 q->connect(control, &QPlatformCamera::errorChanged, q, &QCamera::errorChanged);
171 q->connect(control, &QPlatformCamera::errorOccurred, q, &QCamera::errorOccurred);
462void QCamera::setCameraDevice(
const QCameraDevice &cameraDevice)
465 auto dev = cameraDevice;
467 dev = QMediaDevices::defaultVideoInput();
468 if (d->cameraDevice == dev)
470 d->cameraDevice = dev;
472 d->control->setCamera(d->cameraDevice);
473 emit cameraDeviceChanged();
1321void QCamera::setWhiteBalanceMode(QCamera::WhiteBalanceMode mode)
1326 if (!d->control->isWhiteBalanceModeSupported(mode))
1328 d->control->setWhiteBalanceMode(mode);
1329 if (mode == QCamera::WhiteBalanceManual)
1330 d->control->setColorTemperature(5600);
1382void QCamera::setColorTemperature(
int colorTemperature)
1387 if (colorTemperature < 0)
1388 colorTemperature = 0;
1389 if (colorTemperature == 0) {
1390 d->control->setWhiteBalanceMode(WhiteBalanceAuto);
1391 }
else if (!isWhiteBalanceModeSupported(WhiteBalanceManual)) {
1394 d->control->setWhiteBalanceMode(WhiteBalanceManual);
1396 d->control->setColorTemperature(colorTemperature);