A minimal, portable camera preview + still capture demo using Qt Multimedia.
- Detects first available camera
- Live preview inside a
QVideoWidget - Capture JPEG/PNG to disk on button press
- Pure Qt (no external libs)
- Qt 6.6+ (tested with 6.7.x)
- CMake 3.21+
mkdir -p build cmake -S . -B build -DCMAKE_PREFIX_PATH=/path/to/Qt/6.x/gcc_64 cmake --build build -j ./build/QtCameraDemocmake -S . -B build -G "Ninja" -DCMAKE_PREFIX_PATH=C:\Qt\6.x\msvc2022_64 cmake --build build build\QtCameraDemo.execmake -S . -B build -DCMAKE_PREFIX_PATH="$(brew --prefix qt)" cmake --build build -j open build/QtCameraDemo.appFor redistribution on macOS:
/opt/homebrew/opt/qt/bin/macdeployqt build/QtCameraDemo.app -verbose=2
- macOS: Info.plist declares
NSCameraUsageDescription. First run will prompt for access. If you denied earlier:tccutil reset Camera com.ialexpobad.qtcamerademo - Windows / Linux: Normally no per-app prompt; ensure your OS privacy and device permissions allow camera use.
CameraWidgetsets upQMediaCaptureSession→QCamera→QVideoWidget+QImageCapture.PlatformPermissions_mac.mmrequests camera permission (macOS only).StaticPlugins.cppimports the darwin camera-permission plugin for Homebrew Qt.MainWindowhosts the widget;main.cppcreates the app.
- Add device selection (already in toolbar).
- Add video recording via
QMediaRecorder. - Port to QML by replacing the widget UI with
VideoOutput+MediaCaptureSession.
