Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved QCameraInfo::availableCameras() does not respect user's privacy settings on Windows 10

    General and Desktop
    qcamerainfo qcamera windows 10
    2
    2
    578
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      manicaesar last edited by

      Hi,
      On Windows 10, if you go to Settings -> Privacy -> Camera and switch off 'Allow apps to access your camera', QCameraInfo::availableCameras() still returns the camera (in my case, it returns 1).

      I used QtCreator and created sample Qt Widgets Application, then modified main.cpp to be:

      #include "mainwindow.h"
      #include <QApplication>
      #include <QtMultimedia/QCameraInfo>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
      
          QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
          qInfo() << "Length is " << cameras.length();
          QCamera* camera = new QCamera(cameras.first());
          qInfo() << "status : " << camera->status();
      
          MainWindow w;
          w.show();
      
          return a.exec();
      }
      

      I also added 'multimedia' to 'QT' in .pro file:

      QT       += core gui multimedia
      

      The output produced by the application is as follows:

      Length is  1
      status :  QCamera::UnloadedStatus
      

      I would rather expect it to be 0 or 'QCamera::UnavailableStatus'.

      Is there a way to detect that user has disabled access to camera?

      I am using Qt 5.11.1.

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi and welcome to devnet,

        Qt uses native system call for that task so it returns whatever Windows wants to communicate about the hardware.

        However listing and accessing are likely two different independent aspects.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 2
        • First post
          Last post