QCameraDevice Class

The QCameraDevice class provides general information about camera devices. 更多...

头: #include <QCameraDevice>
CMake: find_package(Qt6 COMPONENTS Multimedia REQUIRED)
target_link_libraries(mytarget PRIVATE Qt6::Multimedia)
qmake: QT += multimedia

公共类型

enum Position { UnspecifiedPosition, BackFace, FrontFace }

公共函数

  QCameraDevice (const QCameraDevice & other )
  QCameraDevice ()
QCameraDevice & operator= (const QCameraDevice & other )
  ~QCameraDevice ()
QString description () const
QByteArray id () const
bool isDefault () const
bool isNull () const
QList<QSize> photoResolutions () const
QCameraDevice::Position position () const
QList<QCameraFormat> videoFormats () const
bool operator!= (const QCameraDevice & other ) const
bool operator== (const QCameraDevice & other ) const

详细描述

QCameraDevice represents a physical camera device and its properties.

You can discover what cameras are available on a system using the availableCameras() and defaultCamera() functions. These are contained within QtMultimedia::MediaDevices.

This example prints the name of all available cameras:

const QList<QCameraDevice> cameras = QMediaDevices::videoInputs();
for (const QCameraDevice &cameraDevice : cameras)
    qDebug() << cameraDevice.description();
					

A QCameraDevice can be used to construct a QCamera . The following example instantiates a QCamera whose camera device is named mycamera :

const QList<QCameraDevice> cameras = QMediaDevices::videoInputs();
for (const QCameraDevice &cameraDevice : cameras) {
    if (cameraDevice.description() == "mycamera")
        camera = new QCamera(cameraDevice);
}
					

You can also use QCameraDevice to get general information about a camera device such as description, physical position on the system, or camera sensor orientation.

QCamera myCamera;
QCameraDevice cameraDevice = camera->cameraDevice();
if (cameraDevice.position() == QCameraDevice::FrontFace)
    qDebug() << "The camera is on the front face of the hardware system.";
else if (cameraDevice.position() == QCameraDevice::BackFace)
    qDebug() << "The camera is on the back face of the hardware system.";
qDebug() << "The camera sensor orientation is " << cameraDevice.orientation() << " degrees.";
					

另请参阅 QCamera .

成员类型文档编制

enum QCameraDevice:: Position

This enum specifies the physical position of the camera on the system hardware.

常量 描述
QCameraDevice::UnspecifiedPosition 0 The camera position is unspecified or unknown.
QCameraDevice::BackFace 1 The camera is on the back face of the system hardware. For example on a mobile device, it means it is on the opposite side to that of the screen.
QCameraDevice::FrontFace 2 The camera is on the front face of the system hardware. For example on a mobile device, it means it is on the same side as that of the screen.

另请参阅 position ().

成员函数文档编制

QCameraDevice:: QCameraDevice (const QCameraDevice & other )

构造副本为 other .

QCameraDevice:: QCameraDevice ()

Constructs a null camera device

QCameraDevice &QCameraDevice:: operator= (const QCameraDevice & other )

设置 QCameraDevice 对象等于 other .

QCameraDevice:: ~QCameraDevice ()

销毁 QCameraDevice .

QString QCameraDevice:: description () const

Returns the human-readable description of the camera.

Use this string to present the device to the user.

注意: Getter function for property description.

QByteArray QCameraDevice:: id () const

Returns the device id of the camera

This is a unique ID to identify the camera and may not be human-readable.

注意: Getter function for property id.

bool QCameraDevice:: isDefault () const

Returns true if this is the default camera device.

注意: Getter function for property isDefault.

bool QCameraDevice:: isNull () const

返回 true,若此 QCameraDevice is null or invalid.

QList < QSize > QCameraDevice:: photoResolutions () const

Returns a list of resolutions that the camera can use to capture still images.

另请参阅 QImageCapture .

QCameraDevice::Position QCameraDevice:: position () const

Returns the physical position of the camera on the hardware system.

注意: Getter 函数对于特性 position。

QList < QCameraFormat > QCameraDevice:: videoFormats () const

Returns the video formats supported by the camera.

注意: Getter function for property videoFormats.

bool QCameraDevice:: operator!= (const QCameraDevice & other ) const

返回 true,若此 QCameraDevice is different from other .

bool QCameraDevice:: operator== (const QCameraDevice & other ) const

返回 true,若此 QCameraDevice 等于 other .