Properties not accessible, of a custom QML type
-
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 -
It should work. what is the error ?
-