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. Properties not accessible, of a custom QML type
Forum Updated to NodeBB v4.3 + New Features

Properties not accessible, of a custom QML type

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 318 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.
  • A Offline
    A Offline
    AhsanKhan
    wrote on last edited by
    #1

    I'm trying to create a custom dialog, which seems to be wasting unexpected amount of my time.

    // CameraDialog.qml
    import QtCore
    import QtQuick
    import QtQuick.Controls
    import QtQuick.Layouts
    import QtQuick.Dialogs
    
    Dialog {
        id: root
    
        property string source: ""
    
        implicitHeight: 150
        implicitWidth: 100
    
        title: "Select a Camera"
        standardButtons: Dialog.Ok | Dialog.Cancel
    
        readonly property list<string> sources: ["Local File", "Remote Camera"]
        readonly property list<string> placeholderForSource: ["Enter file path here", "Enter camera url here"]
    
        ColumnLayout {
            anchors.fill: parent
            anchors.margins: 30
            clip: true
    
            ComboBox {
                id: sourceComboBox
                Layout.fillWidth: true
                Layout.alignment: Qt.AlignLeft | Qt.AlignTop
    
                model: root.sources
            }
    
            RowLayout {
                Layout.alignment: Qt.AlignLeft | Qt.AlignTop
    
                TextField {
                    // Layout.fillHeight: true
                    Layout.fillWidth: true
                    placeholderText: root.placeholderForSource[sourceComboBox.currentIndex]
                }
    
                Button {
                    Layout.preferredHeight: 40
    
                    visible: sourceComboBox.currentIndex === 0
                    text: "Browse"
                    onClicked: function () {
                        fileDialog.open()
                    }
                }
    
                // TODO: Force video file selection by formats
                FileDialog {
                    id: fileDialog
    
                    currentFolder: StandardPaths.writableLocation(StandardPaths.MoviesLocation)
                    onSelectedFileChanged: root.source = fileDialog.selectedFile
                }
            }
        }
    }
    

    and I'm using it like this:

    pragma ComponentBehavior: Bound
    import QtQuick
    import QtQuick.Controls
    import QtQuick.Layouts
    import QtMultimedia
    import APSS
    
    Page {
        id: root
    
        signal stopped()
    
        ColumnLayout {
            anchors.fill: parent
            anchors.margins: 20
            spacing: 10
    
            // Video Playback Screen
            Rectangle {
                Layout.fillHeight: true
                Layout.fillWidth: true
                color: "black"
    
                VideoOutput {
                    id: videoOutput
                    anchors.fill: parent
                }
    
                ListView {
                    id: detections
    
                    anchors {
                        left: parent.left
                        bottom: parent.bottom
                        right: parent.right
                        margins: 10
                    }
                    height: 110
                    spacing: 10
                    // model: apssEngine.licenseplatePaths
                    clip: true
                    orientation: Qt.Horizontal
                    delegate: Rectangle {
                        width: 160
                        height: detections.height
                        color: "#D9D9D9"
                    }
                }
            }
    
            Row {
                spacing: 10
                Layout.alignment: Qt.AlignHCenter
    
                Button {
                    id: selectButton
    
                    text: "Select"
                    onClicked: function () {
                        cameraDialog.open()
                    }
                }
    
                CameraDialog {
                    id: cameraDialog
    
                    modal: true
                    onAccepted: function () {
                        apssEngine.openAFootage(cameraDialog.source, videoOutput.videoSink)
                    }
                }
            }
        }
    }
    

    Neither of CameraDialog properties are accessible when used in other qml files, including inherited ones. Why?

    Windows 11
    Qt 6.9
    MSVC 19

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      It should work. what is the error ?

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      1
      • A Offline
        A Offline
        AhsanKhan
        wrote on last edited by
        #3

        Sorry man, my bad. I had a conflicting and similar type somewhere else named CameraDialog in APSS module. I don't know why QML Engine did not prefer the one in the same directory over the other. But it's solved.

        1 Reply Last reply
        0
        • A AhsanKhan has marked this topic as solved on

        • Login

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