Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
devices.cpp
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4#include <QAudioDevice>
5#include <QCameraDevice>
6#include <QMediaDevices>
7#include <QString>
8#include <QTextStream>
9
10int main(int argc, char *argv[])
11{
12 Q_UNUSED(argc);
13 Q_UNUSED(argv);
14
15 QTextStream out(stdout);
16
17 //! [Media Audio Input Device Enumeration]
18 const QList<QAudioDevice> audioDevices = QMediaDevices::audioInputs();
19 for (const QAudioDevice &device : audioDevices)
20 {
21 out << "ID: " << device.id() << Qt::endl;
22 out << "Description: " << device.description() << Qt::endl;
23 out << "Is default: " << (device.isDefault() ? "Yes" : "No") << Qt::endl;
24 }
25 //! [Media Audio Input Device Enumeration]
26
27 //! [Media Video Input Device Enumeration]
28 const QList<QCameraDevice> videoDevices = QMediaDevices::videoInputs();
29 for (const QCameraDevice &device : videoDevices)
30 {
31 out << "ID: " << device.id() << Qt::endl;
32 out << "Description: " << device.description() << Qt::endl;
33 out << "Is default: " << (device.isDefault() ? "Yes" : "No") << Qt::endl;
34 }
35 //! [Media Video Input Device Enumeration]
36
37 return 0;
38}
int main(int argc, char *argv[])
[ctor_close]