How can I convert a QJSValue List into a QString List?
-
I'm new to QtQuick, here's my problem.
I like to put a set of available cameras connected to my computer in a combo box. However, when I use the QtMultimedia.availableCameras, the list is in QJSValue instead of QString.
Is there any method or functions that I can use to get the list of camera names?So far my combo box has shown 2 spaces, blank. So I know it has the value that it has 2 items in the list, but couldn't display the name.
Thank you for your help, much appreciated. -
I couldn't get availableCameras to work as documented (I got an array of strings back), but I think it's supposed to work like this:
ComboBox { model: ListModel { } Component.onCompleted: { for (var camera in QtMultimedia.availableCameras) model.append({ "text": camera.displayName }) } }
-
@xargs1 said:
In order to get availableCameras to work, you have to first import QtMultimedia 5.4
Can we just give ListModel an empty set of bracket?
This didn't work, it says
modelData is not definedShould I write part of the code in another QML file?
-
Hello, I had the same problem with showing the list of cameras in a ComboBox. the correct code is:
ComboBox { id: cmbVideoCaptures model: QtMultimedia.availableCameras textRole: "displayName" valueRole: "deviceId" }