Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Qt6 QML Loader doesn't work with CaptureSession

Qt6 QML Loader doesn't work with CaptureSession

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 260 Views
  • 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.
  • C Offline
    C Offline
    charlie2024
    wrote on last edited by
    #1

    This has been driving me crazy for a few days now. For some reason, I cannot get Camera to work with Loader. I want dynamic loading because the underlying video device can be fickle, and I'd like the UI to automatically recover from it.

    Here is the code:

    import QtQuick 2.15
    import QtMultimedia 6.6
    import QtQuick.Controls 2.12
    import "../../shared"
    
    Item {
        property string cameraDeviceName
        property var selectedDevice 
    
        MediaDevices {
            id: mediaDevices
        }
    
        // Loader {
        //     id: captureSessionLoader
        //     active: true
        //     sourceComponent: captureSessionComponent 
        //     onLoaded: {
        //       console.log("Component loaded:", captureSessionLoader.sourceComponent == captureSessionComponent ? "Capture Session" : "Empty Component");
        //     }
        // }
    
        // Component {
        //     id: captureSessionComponent
            CaptureSession {
                camera: Camera {
                    id: camera
                    cameraDevice: mediaDevices.videoInputs[0]
                    active: true
                    onErrorOccurred: {
                        console.log("Camera object has some error", errorString)
                    }
                }
    
                videoOutput: videoOutput
            }
        // }
    
        VideoOutput {
            id: videoOutput
            anchors.fill: parent
        }
    }
    

    Here is what I am trying to figure out:

    1. If I comment out the Loader code, and start the UI, the camera shows up fine.
    2. If I uncomment the Loader code, and start the UI, nothing shows up on the screen.
    3. I tried replace CaptureSession with a simple rectangle, it would show up on the screen fine.

    So apparently something is wrong with Loader working with CaptureSession, but I cannot figure out what. I do not see any errors being printed out on the console. And I do see Component loaded every time I start the UI, so it's not an issue with not loader not loading.

    Thanks for any comments!

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved