MeeGo 1.2 Harmattan Developer Documentation Develop for the Nokia N9

QDeclarativeCamera Class Reference

The QDeclarativeCamera class provides a camera item that you can add to a QDeclarativeView. More...

 #include <QDeclarativeCamera>

Inherits: QDeclarativeItem.

This class was introduced in Mobility 1.1.

Public Types

enum Error { NoError, CameraError, InvalidRequestError, ServiceMissingError, NotSupportedFeatureError }
enum ExposureMode { ExposureManual, ExposureAuto, ExposureNight, ExposureBacklight, ..., ExposureModeVendor }
enum FlashMode { FlashOff, FlashOn, FlashAuto, FlashRedEyeReduction, ..., FlashManual }
enum LockStatus { Unlocked, Searching, Locked }
enum State { UnloadedState, LoadedState, ActiveState }
enum WhiteBalanceMode { WhiteBalanceManual, WhiteBalanceAuto, WhiteBalanceSunlight, WhiteBalanceCloudy, ..., WhiteBalanceVendor }

Properties

Public Functions

QDeclarativeCamera ( QDeclarativeItem * parent = 0 )
~QDeclarativeCamera ()
qreal aperture () const
State cameraState () const
QSize captureResolution () const
QString capturedImagePath () const
QImage capturedImagePreview () const
qreal digitalZoom () const
Error error () const
QString errorString () const
qreal exposureCompensation () const
ExposureMode exposureMode () const
int flashMode () const
int isoSensitivity () const
LockStatus lockStatus () const
int manualWhiteBalance () const
qreal maximumDigitalZoom () const
qreal maximumOpticalZoom () const
qreal opticalZoom () const
qreal shutterSpeed () const
WhiteBalanceMode whiteBalanceMode () const

Reimplemented Public Functions

virtual void paint ( QPainter * painter, const QStyleOptionGraphicsItem * style, QWidget * widget )

Public Slots

void captureImage ()
void searchAndLock ()
void setCameraState ( State state )
void setCaptureResolution ( const QSize & size )
void setDigitalZoom ( qreal )
void setExposureCompensation ( qreal ev )
void setExposureMode ( QDeclarativeCamera::ExposureMode )
void setFlashMode ( int )
void setManualIsoSensitivity ( int iso )
void setManualWhiteBalance ( int colorTemp ) const
void setOpticalZoom ( qreal )
void setWhiteBalanceMode ( QDeclarativeCamera::WhiteBalanceMode mode ) const
void start ()
void stop ()
void unlock ()
  • 1 public slot inherited from QObject

Signals

void apertureChanged ( qreal aperture )
void cameraStateChanged ( QDeclarativeCamera::State state )
void captureFailed ( const QString & message )
void captureResolutionChanged ( const QSize & resolution )
void digitalZoomChanged ( qreal )
void error ( QDeclarativeCamera::Error error, const QString & errorString )
void errorChanged ()
void exposureCompensationChanged ( qreal expComp )
void exposureModeChanged ( QDeclarativeCamera::ExposureMode mode )
void flashModeChanged ( int )
void imageCaptured ( const QString & preview )
void imageSaved ( const QString & path )
void isoSensitivityChanged ( int isoValue )
void lockStatusChanged ()
void manualWhiteBalanceChanged ( int newWhiteBal ) const
void maximumDigitalZoomChanged ( qreal zoom )
void maximumOpticalZoomChanged ( qreal )
void opticalZoomChanged ( qreal zoom )
void shutterSpeedChanged ( qreal speed )
void whiteBalanceModeChanged ( QDeclarativeCamera::WhiteBalanceMode ) const

Reimplemented Protected Functions

virtual void geometryChanged ( const QRectF & newGeometry, const QRectF & oldGeometry )
virtual void keyPressEvent ( QKeyEvent * event )
virtual void keyReleaseEvent ( QKeyEvent * event )

Additional Inherited Members

Detailed Description

The QDeclarativeCamera class provides a camera item that you can add to a QDeclarativeView.

Member Type Documentation

enum QDeclarativeCamera::Error

Constant Value Description
QDeclarativeCamera::NoError QCamera::NoError No errors have occurred.
QDeclarativeCamera::CameraError QCamera::CameraError An error has occurred.
QDeclarativeCamera::InvalidRequestError QCamera::InvalidRequestError System resource doesn't support requested functionality.
QDeclarativeCamera::ServiceMissingError QCamera::ServiceMissingError No camera service available.
QDeclarativeCamera::NotSupportedFeatureError QCamera::NotSupportedFeatureError The feature is not supported.

enum QDeclarativeCamera::ExposureMode

Constant Value Description
QDeclarativeCamera::ExposureManual 1 Manual mode.
QDeclarativeCamera::ExposureAuto 0 Automatic mode.
QDeclarativeCamera::ExposureNight 3 Night mode.
QDeclarativeCamera::ExposureBacklight 4 Backlight exposure mode.
QDeclarativeCamera::ExposureSpotlight 5 Spotlight exposure mode.
QDeclarativeCamera::ExposureSports 6 Spots exposure mode.
QDeclarativeCamera::ExposureSnow 7 Snow exposure mode.
QDeclarativeCamera::ExposureBeach 8 Beach exposure mode.
QDeclarativeCamera::ExposureLargeAperture 9 Use larger aperture with small depth of field.
QDeclarativeCamera::ExposureSmallAperture 10 Use smaller aperture.
QDeclarativeCamera::ExposurePortrait 2 Portrait exposure mode.
QDeclarativeCamera::ExposureModeVendor 1000 The base value for device specific exposure modes.

enum QDeclarativeCamera::FlashMode

Constant Value Description
QDeclarativeCamera::FlashOff 0x2 Flash is Off.
QDeclarativeCamera::FlashOn 0x4 Flash is On.
QDeclarativeCamera::FlashAuto 0x1 Automatic flash.
QDeclarativeCamera::FlashRedEyeReduction 0x8 Red eye reduction flash.
QDeclarativeCamera::FlashFill 0x10 Use flash to fillin shadows.
QDeclarativeCamera::FlashTorch 0x20 Constant light source, useful for focusing and video capture.
QDeclarativeCamera::FlashSlowSyncFrontCurtain 0x40 Use the flash in conjunction with a slow shutter speed. This mode allows better exposure of distant objects and/or motion blur effect.
QDeclarativeCamera::FlashSlowSyncRearCurtain 0x80 The similar mode to FlashSlowSyncFrontCurtain but flash is fired at the end of exposure.
QDeclarativeCamera::FlashManual 0x100 Flash power is manually set.

enum QDeclarativeCamera::LockStatus

Constant Value Description
QDeclarativeCamera::Unlocked QCamera::Unlocked The application is not interested in camera settings value. The camera may keep this parameter without changes, this is common with camera focus, or adjust exposure and white balance constantly to keep the viewfinder image nice.
QDeclarativeCamera::Searching QCamera::Searching The application has requested the camera focus, exposure or white balance lock with searchAndLock(). This state indicates the camera is focusing or calculating exposure and white balance.
QDeclarativeCamera::Locked QCamera::Locked The camera focus, exposure or white balance is locked. The camera is ready to capture, application may check the exposure parameters.

The locked state usually means the requested parameter stays the same, except in the cases when the parameter is requested to be constantly updated. For example in continuous focusing mode, the focus is considered locked as long and the object is in focus, even while the actual focusing distance may be constantly changing.

enum QDeclarativeCamera::State

Constant Value Description
QDeclarativeCamera::UnloadedState QCamera::UnloadedState The initial camera state, with camera not loaded, the camera capabilities except of supported capture modes are unknown. While the supported settings are unknown in this state, it's allowed to set the camera capture settings like codec, resolution, or frame rate.
QDeclarativeCamera::LoadedState QCamera::LoadedState The camera is loaded and ready to be configured. In the Idle state it's allowed to query camera capabilities, set capture resolution, codecs, etc. The viewfinder is not active in the loaded state.
QDeclarativeCamera::ActiveState QCamera::ActiveState In the active state as soon as camera is started the viewfinder displays video frames and the camera is ready for capture.

The default camera state is ActiveState.

enum QDeclarativeCamera::WhiteBalanceMode

Constant Value Description
QDeclarativeCamera::WhiteBalanceManual 1 Manual white balance. In this mode the manual white balance property value is used.
QDeclarativeCamera::WhiteBalanceAuto 0 Auto white balance mode.
QDeclarativeCamera::WhiteBalanceSunlight 2 Sunlight white balance mode.
QDeclarativeCamera::WhiteBalanceCloudy 3 Cloudy white balance mode.
QDeclarativeCamera::WhiteBalanceShade 4 Shade white balance mode.
QDeclarativeCamera::WhiteBalanceTungsten 5 Tungsten white balance mode.
QDeclarativeCamera::WhiteBalanceFluorescent 6 Fluorescent white balance mode.
QDeclarativeCamera::WhiteBalanceIncandescent 7 Incandescent white balance mode.
QDeclarativeCamera::WhiteBalanceFlash 8 Flash white balance mode.
QDeclarativeCamera::WhiteBalanceSunset 9 Sunset white balance mode.
QDeclarativeCamera::WhiteBalanceVendor 1000 Vendor defined white balance mode.

Property Documentation

aperture : const qreal

The lens aperture as an F number (the ratio of the focal length to effective aperture diameter).

This property was introduced in Mobility 1.1.

Access functions:

qreal aperture () const

Notifier signal:

void apertureChanged ( qreal aperture )

cameraState : State

The current state of the camera object.

Value Description
UnloadedState The initial camera state, with camera not loaded, the camera capabilities except of supported capture modes are unknown. While the supported settings are unknown in this state, it's allowed to set the camera capture settings like codec, resolution, or frame rate.
LoadedState The camera is loaded and ready to be configured.

In the Idle state it's allowed to query camera capabilities, set capture resolution, codecs, etc.

The viewfinder is not active in the loaded state.

ActiveState In the active state as soon as camera is started the viewfinder displays video frames and the camera is ready for capture.

This property was introduced in Mobility 1.1.

Access functions:

State cameraState () const
void setCameraState ( State state )

Notifier signal:

void cameraStateChanged ( QDeclarativeCamera::State state )

captureResolution : QSize

The resolution to capture the image at. If empty, the system will pick a good size.

This property was introduced in Mobility 1.1.

Access functions:

QSize captureResolution () const
void setCaptureResolution ( const QSize & size )

Notifier signal:

void captureResolutionChanged ( const QSize & resolution )

capturedImagePath : const QString

The path to the captured image.

This property was introduced in Mobility 1.1.

Access functions:

QString capturedImagePath () const

Notifier signal:

void imageSaved ( const QString & path )

digitalZoom : qreal

The current digital zoom factor.

This property was introduced in Mobility 1.1.

Access functions:

qreal digitalZoom () const
void setDigitalZoom ( qreal )

Notifier signal:

void digitalZoomChanged ( qreal )

errorString : const QString

A description of the current error, if any.

This property was introduced in Mobility 1.1.

Access functions:

QString errorString () const

Notifier signal:

void errorChanged ()

exposureCompensation : qreal

Adjustment for the automatically calculated exposure. The value is in EV units.

This property was introduced in Mobility 1.1.

Access functions:

qreal exposureCompensation () const
void setExposureCompensation ( qreal ev )

Notifier signal:

void exposureCompensationChanged ( qreal expComp )

exposureMode : ExposureMode

Camera exposure modes.

This property was introduced in Mobility 1.1.

Access functions:

ExposureMode exposureMode () const
void setExposureMode ( QDeclarativeCamera::ExposureMode )

Notifier signal:

void exposureModeChanged ( QDeclarativeCamera::ExposureMode mode )

flashMode : int

Value Description
FlashOff Flash is Off.
FlashOn Flash is On.
FlashAuto Automatic flash.
FlashRedEyeReduction Red eye reduction flash.
FlashFill Use flash to fillin shadows.
FlashTorch Constant light source, useful for focusing and video capture.
FlashSlowSyncFrontCurtain Use the flash in conjunction with a slow shutter speed. This mode allows better exposure of distant objects and/or motion blur effect.
FlashSlowSyncRearCurtain The similar mode to FlashSlowSyncFrontCurtain but flash is fired at the end of exposure.
FlashManual Flash power is manually set.

This property was introduced in Mobility 1.1.

Access functions:

int flashMode () const
void setFlashMode ( int )

Notifier signal:

void flashModeChanged ( int )

iso : int

The sensor's ISO sensitivity.

This property was introduced in Mobility 1.1.

Access functions:

int isoSensitivity () const
void setManualIsoSensitivity ( int iso )

Notifier signal:

void isoSensitivityChanged ( int isoValue )

lockStatus : const LockStatus

The overall status for all the requested camera locks.

Value Description
Unlocked The application is not interested in camera settings value. The camera may keep this parameter without changes, this is common with camera focus, or adjust exposure and white balance constantly to keep the viewfinder image nice.
Searching The application has requested the camera focus, exposure or white balance lock with searchAndLock(). This state indicates the camera is focusing or calculating exposure and white balance.
Locked The camera focus, exposure or white balance is locked. The camera is ready to capture, application may check the exposure parameters.

The locked state usually means the requested parameter stays the same, except in the cases when the parameter is requested to be constantly updated. For example in continuous focusing mode, the focus is considered locked as long and the object is in focus, even while the actual focusing distance may be constantly changing.

This property was introduced in Mobility 1.1.

Access functions:

LockStatus lockStatus () const

Notifier signal:

void lockStatusChanged ()

manualWhiteBalance : int

The color temperature used when in manual white balance mode (WhiteBalanceManual).

This property was introduced in Mobility 1.1.

Access functions:

int manualWhiteBalance () const
void setManualWhiteBalance ( int colorTemp ) const

Notifier signal:

void manualWhiteBalanceChanged ( int newWhiteBal ) const

See also whiteBalanceMode.

maximumDigitalZoom : const qreal

The maximum digital zoom factor, or 1.0 if digital zoom is not supported.

This property was introduced in Mobility 1.1.

Access functions:

qreal maximumDigitalZoom () const

Notifier signal:

void maximumDigitalZoomChanged ( qreal zoom )

maximumOpticalZoom : const qreal

The maximum optical zoom factor, or 1.0 if optical zoom is not supported.

This property was introduced in Mobility 1.1.

Access functions:

qreal maximumOpticalZoom () const

Notifier signal:

void maximumOpticalZoomChanged ( qreal )

opticalZoom : qreal

The current optical zoom factor.

This property was introduced in Mobility 1.1.

Access functions:

qreal opticalZoom () const
void setOpticalZoom ( qreal )

Notifier signal:

void opticalZoomChanged ( qreal zoom )

shutterSpeed : const qreal

The camera's shutter speed, in seconds.

This property was introduced in Mobility 1.1.

Access functions:

qreal shutterSpeed () const

Notifier signal:

void shutterSpeedChanged ( qreal speed )

whiteBalanceMode : WhiteBalanceMode

This property was introduced in Mobility 1.1.

Access functions:

WhiteBalanceMode whiteBalanceMode () const
void setWhiteBalanceMode ( QDeclarativeCamera::WhiteBalanceMode mode ) const

Notifier signal:

void whiteBalanceModeChanged ( QDeclarativeCamera::WhiteBalanceMode ) const

See also WhiteBalanceMode.

Member Function Documentation

QDeclarativeCamera::QDeclarativeCamera ( QDeclarativeItem * parent = 0 )

Construct a declarative camera object using parent object.

QDeclarativeCamera::~QDeclarativeCamera ()

Destructor, clean up memory

void QDeclarativeCamera::apertureChanged ( qreal aperture ) [signal]

Signals the change to a new aperture value.

This function was introduced in Mobility 1.1.

void QDeclarativeCamera::cameraStateChanged ( QDeclarativeCamera::State state ) [signal]

The camera state has changed to value state.

This function was introduced in Mobility 1.1.

void QDeclarativeCamera::captureFailed ( const QString & message ) [signal]

This handler is called when an error occurs during capture. A descriptive message is available in message.

This function was introduced in Mobility 1.1.

void QDeclarativeCamera::captureImage () [slot]

Start image capture. The onImageCaptured() and onImageSaved() signals will be emitted when the capture is complete.

This function was introduced in Mobility 1.1.

void QDeclarativeCamera::captureResolutionChanged ( const QSize & resolution ) [signal]

Signal that the resolution has changed to resolution.

This function was introduced in Mobility 1.1.

QImage QDeclarativeCamera::capturedImagePreview () const

This function was introduced in Mobility 1.1.

void QDeclarativeCamera::digitalZoomChanged ( qreal ) [signal]

This function was introduced in Mobility 1.1.

Error QDeclarativeCamera::error () const

Returns any camera error.

This function was introduced in Mobility 1.1.

See also QDeclarativeCamera::Error.

void QDeclarativeCamera::error ( QDeclarativeCamera::Error error, const QString & errorString ) [signal]

This handler is called when an error occurs. The enumeration value error is one of the values defined below, and a descriptive string value is available in errorString.

Value Description
NoError No errors have occurred.
CameraError An error has occurred.
InvalidRequestError System resource doesn't support requested functionality.
ServiceMissingError No camera service available.
NotSupportedFeatureError The feature is not supported.

This function was introduced in Mobility 1.1.

See also QDeclarativeCamera::Error.

void QDeclarativeCamera::errorChanged () [signal]

This function was introduced in Mobility 1.1.

void QDeclarativeCamera::exposureCompensationChanged ( qreal expComp ) [signal]

Compensation has changed to the new value expComp.

This function was introduced in Mobility 1.1.

void QDeclarativeCamera::exposureModeChanged ( QDeclarativeCamera::ExposureMode mode ) [signal]

Signals that the exposure mode is now mode.

This function was introduced in Mobility 1.1.

void QDeclarativeCamera::flashModeChanged ( int ) [signal]

This function was introduced in Mobility 1.1.

void QDeclarativeCamera::geometryChanged ( const QRectF & newGeometry, const QRectF & oldGeometry ) [virtual protected]

Reimplemented from QDeclarativeItem::geometryChanged().

Change viewfinder size to newGeometry and returning the oldGeometry

This function was introduced in Mobility 1.1.

void QDeclarativeCamera::imageCaptured ( const QString & preview ) [signal]

This handler is called when an image has been captured but not yet saved to the filesystem. The preview parameter can be used as the URL supplied to an Image element.

This function was introduced in Mobility 1.1.

See also imageSaved().

void QDeclarativeCamera::imageSaved ( const QString & path ) [signal]

This handler is called after the image has been written to the filesystem. The path is a local file path, not a URL.

This function was introduced in Mobility 1.1.

See also imageCaptured().

void QDeclarativeCamera::isoSensitivityChanged ( int isoValue ) [signal]

The iso value has changed to isoValue.

This function was introduced in Mobility 1.1.

void QDeclarativeCamera::keyPressEvent ( QKeyEvent * event ) [virtual protected]

Reimplemented from QGraphicsItem::keyPressEvent().

Handler for keypress events. The event is compared to a small set of events.

This function was introduced in Mobility 1.1.

void QDeclarativeCamera::keyReleaseEvent ( QKeyEvent * event ) [virtual protected]

Reimplemented from QGraphicsItem::keyReleaseEvent().

Handle the release of a key in event and take action if needed.

This function was introduced in Mobility 1.1.

void QDeclarativeCamera::lockStatusChanged () [signal]

This function was introduced in Mobility 1.1.

void QDeclarativeCamera::manualWhiteBalanceChanged ( int newWhiteBal ) const [signal]

Indicates that the white balance has been manually changed to newWhiteBal.

This function was introduced in Mobility 1.1.

void QDeclarativeCamera::maximumDigitalZoomChanged ( qreal zoom ) [signal]

The maximum digital zoom is now zoom.

This function was introduced in Mobility 1.1.

void QDeclarativeCamera::maximumOpticalZoomChanged ( qreal ) [signal]

void QDeclarativeCamera::opticalZoomChanged ( qreal zoom ) [signal]

Optical zoom changed to zoom.

This function was introduced in Mobility 1.1.

void QDeclarativeCamera::paint ( QPainter * painter, const QStyleOptionGraphicsItem * style, QWidget * widget ) [virtual]

Reimplemented from QGraphicsItem::paint().

Paint method. Takes a painter object, a graphics style option and a widget

This function was introduced in Mobility 1.1.

void QDeclarativeCamera::searchAndLock () [slot]

Start focusing, exposure and white balance calculation. If the camera has keyboard focus, searchAndLock() is called automatically when the camera focus button is pressed.

This function was introduced in Mobility 1.1.

void QDeclarativeCamera::shutterSpeedChanged ( qreal speed ) [signal]

The shutter speed has been changed to speed.

This function was introduced in Mobility 1.1.

void QDeclarativeCamera::start () [slot]

Starts the camera.

This function was introduced in Mobility 1.1.

void QDeclarativeCamera::stop () [slot]

Stops the camera.

This function was introduced in Mobility 1.1.

void QDeclarativeCamera::unlock () [slot]

Unlock focus.

If the camera has keyboard focus, unlock() is called automatically when the camera focus button is released.

This function was introduced in Mobility 1.1.

void QDeclarativeCamera::whiteBalanceModeChanged ( QDeclarativeCamera::WhiteBalanceMode ) const [signal]

This function was introduced in Mobility 1.1.