Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
625 views
in Technique[技术] by (71.8m points)

macos - qt webengine request camera and mic access on mac

I tried to access the camera and mic using QWebEngineView so I used this code to grand the access on my Mac

I used the solution which is Here it worked fine when I run the app inside QT and it asks me for the first time on my Mac that QT need to access my Mic and Camera which I allow it and it works, the problem is when I use the release version which has all the needed dependencies and stuff, the app crashes and when I check my system preferences for the permission I did not see the app is listed only QT in both Camer and Mic, and I can't add an app manually.

So what is the solution of this problem? to let the app ask for permission instead of crashes? what edit do I need to do to the codes to allow the app to ask for permission as QT does?

Update What I tried as well is to run the app from executable inside the .app or the package which allow the terminal to request permission to the camera and mic and I worked but this not effective solution to ask the user to do so.

Another test I did is to go to the info.plist inside the .app package and add both

  • Privacy - Camra Usage Description
  • Privacy - Microphone Usage Description

after that I test again, the app not crash but the Camera open and then after 1 or two seconds the Camera close that is it, so I think I need to show the Permission dialog box, any help with it or how to show it up?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

after trying many solutions what is worked that I added both permissions to the plist in qt bundle

Privacy - Camra Usage Description
Privacy - Microphone Usage Description

but with values 6.0 or any other value that not have space or long characters, and it worked! and it shows me the permission box and added the app to the privacy in system preferences, maybe long text not let the dialog box show, I am not sure exactly.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...