StackView not open Item
Solved
Mobile and Embedded
-
Good morning, in the main I have a stackview to open the pages, I have a problem with "Magazzino" where I have a Button in which I have to open a window where I want to use the camera to scan the barcode, but when I click on the main the "warehouse" page gives me an error:
qrc:/main2.qml:99:5: QML StackView: push: qrc:/Magazzino.qml:207 MainBarcode is not a type
I tried to replace the page with a simple rectangle and a button and it opens quietly, instead if I try to open the page where I have already tested a simple program that works.
MAIN:
import QtQuick 2.0 import QtQuick.Controls 2.5 import QtQuick.Layouts 1.12 import io.qt.Backend 1.0 import QtQuick.Dialogs 1.3 import "BarcodeScan" ApplicationWindow { id: window width: 500 height: 500 visible:true Backend{ id: backend onStatusChanged: { messageDialog.setVisible(true); messageDialog.text = newStatus } } MessageDialog{ id: messageDialog title: "Attenzione" onAccepted: { console.log("message for insert ip start.") // Qt.quit() } // Component.onCompleted: visible = true } Rectangle { id: rectangle color: "#363636" anchors.fill: parent } header: ToolBar { background:Rectangle { implicitHeight: 40 color: "beige" } RowLayout { anchors.fill: parent ToolButton { text: qsTr("‹") onClicked: stackView.pop() } Label { text: "App Paolo" elide: Label.ElideRight horizontalAlignment: Qt.AlignHCenter verticalAlignment: Qt.AlignVCenter Layout.fillWidth: true } ToolButton { text: qsTr("⋮") onClicked: { menu.x = (window.width - menu.width) / 1 menu.y = 10 menu.open() } } } } ListModel { id: pageModel ListElement { title: "Riparazioni" page: "Riparazioni.qml" } ListElement { title: "Magazzino" page: "Magazzino.qml" } } StackView { id: stackView anchors.fill: parent // Implements back key navigation focus: true // //Keys.onReleased: if (event.key === Qt.Key_Back && stackView.depth > 1) { // stackView.pop(); // event.accepted = true; // } initialItem: Item { width: parent.width height: parent.height ListView { model: pageModel anchors.fill: parent delegate: AndroidDelegate { text: title onClicked: { stackView.push(Qt.resolvedUrl(page)) backend.connectClient() } } } } Loader{ id : ld } StackView { id: stack anchors.fill: parent } Menu { id: menu MenuItem{ text: "Settings" onClicked: { stackView.push("Settings.qml") } } } } }
Item MAGAZZINO:
import QtQuick 2.10 import QtQuick.Controls 2.5 import io.qt.Backend 1.0 import QtQuick.Window 2.12 import "BarcodeScan" Item { id: magazzino visible: true property string prezzoCosto: "" property string prezzoPubblico: "" Backend { id: backend onSendCode: {txtCodice.text = code} onSendPCosto:{txtPCosto.text = p_pCosto} onSendPPubblico:{txtPPub.text = p_pPubblico} } Row { id: row1 height: 50 anchors.right: parent.right anchors.rightMargin: 5 anchors.left: parent.left anchors.leftMargin: 5 anchors.top: parent.top anchors.topMargin: 3 Rectangle { id: rectangle_Search height: 70 color: "#0e99b2" radius: 4 anchors.top: parent.verticalCenter anchors.topMargin: -25 anchors.left: parent.left anchors.right: parent.right Text { id:lbl_SearchCode color: "#0a0808" text: qsTr("Codice") anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left anchors.leftMargin: 4 font.pixelSize: 12 } CustomTextEdit { id: c_Txt_codice y: 0 width: 70 height: 30 fontSize: 20 anchors.verticalCenter: parent.verticalCenter anchors.bottom: parent anchors.bottomMargin: 0 anchors.left: lbl_SearchCode.right anchors.leftMargin: 20 } CustomButton { id: btnSearchKey x: 503 y: 3 width: 122 height: 44 text: "CERCA" anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right anchors.rightMargin: 5 anchors.top: parent.verticalCenter anchors.topMargin: -22 color: enabled ? this.down ? "#78C37F" : "#87DB8D" : "gray" onClicked: { backend.connectClient() backend.connectClicked() backend.sendSearch(2,c_Txt_codice.text) } } CustomButton { id: btn_Barcode x: 309 y: 0 width: 121 height: 39 text: "BARCODE" anchors.verticalCenter: parent.verticalCenter focusPolicy: Qt.NoFocus anchors.right: btnSearchKey.left anchors.rightMargin: 10 onClicked: { winBarc.visible = true } } } } Row { id: row2 height: 200 anchors.right: parent.right anchors.rightMargin: 3 anchors.left: parent.left anchors.leftMargin: 3 anchors.top: row1.bottom anchors.topMargin: 50 Rectangle{ id: rectangle_Articolo color: "#0e99b2" radius: 18 anchors.fill: parent Label { id: lbl_PCosto x: 5 width: 63 height: 33 color: "#ebedef" text: "Pr. Costo" anchors.top: parent.top anchors.topMargin: 41 anchors.left: parent.left anchors.leftMargin: 5 } CustomTextEdit { id: txtPCosto width: 105 height: 36 fontSize: 20 anchors.top: parent.top anchors.topMargin: 38 anchors.left: lbl_PCosto.right anchors.leftMargin: 32 text: prezzoCosto } CustomTextEdit { id: txtPPub x: -3 y: -47 width: 105 height: 36 fontSize: 20 anchors.top: txtPCosto.bottom anchors.topMargin: 10 anchors.left: lbl_pPubblioco.right anchors.leftMargin: 32 } Label { id: lbl_pPubblioco x: 2 y: -56 width: 63 height: 36 color: "#ebedef" text: "Pr. Pub." verticalAlignment: Text.AlignVCenter anchors.top: lbl_PCosto.bottom anchors.topMargin: 10 anchors.left: parent.left anchors.leftMargin: 5 } CustomButton { id: btnSalva x: 497 width: 87 height: 39 color: qsTr("#ffffff") text: "SALVA" anchors.verticalCenter: parent.verticalCenter anchors.top: parent.top anchors.topMargin: 50 anchors.right: parent.right anchors.rightMargin: 50 } } } MainBarcode{ id:winBarc } }
THIS IS PAGE FOR OPEN THE LOGIC BARCODE:
import QtQuick.Controls 2.5 import QtQuick 2.0 import QtMultimedia 5.12 import QZXing 2.3 import QtQuick.Dialogs 1.3 import Qt.labs.platform 1.1 Item { id:windowBarcode width: 400 height: 400 visible: false Rectangle { id : cameraUI color: "black" anchors.fill: parent state: "PhotoCapture" states: [ State { name: "PhotoCapture" StateChangeScript { script: { camera.captureMode = Camera.CaptureStillImage camera.start() } } }, State { name: "PhotoPreview" }, State { name: "VideoCapture" StateChangeScript { script: { camera.captureMode = Camera.CaptureVideo camera.start() } } }, State { name: "VideoPreview" StateChangeScript { script: { camera.stop() } } } ] Camera { id: camera captureMode: Camera.CaptureStillImage imageCapture { onImageCaptured: { //photoPreview.source = preview stillControls.previewAvailable = true cameraUI.state = "PhotoPreview" decoder.decodeImageQML(preview); } } videoRecorder { resolution: "640x480" frameRate: 30 } } PhotoPreview { id : photoPreview anchors.fill : parent onClosed: cameraUI.state = "PhotoCapture" visible: cameraUI.state == "PhotoPreview" focus: visible } VideoPreview { id : videoPreview anchors.fill : parent onClosed: cameraUI.state = "VideoCapture" visible: cameraUI.state == "VideoPreview" focus: visible //don't load recorded video if preview is invisible source: visible ? camera.videoRecorder.actualLocation : "" } VideoOutput { id: viewfinder visible: cameraUI.state == "PhotoCapture" || cameraUI.state == "VideoCapture" x: 0 y: 0 width: parent.width - stillControls.buttonsPanelWidth height: parent.height source: camera autoOrientation: true } PhotoCaptureControls { id: stillControls anchors.fill: parent camera: camera visible: cameraUI.state == "PhotoCapture" onPreviewSelected: cameraUI.state = "PhotoPreview" onVideoModeSelected: cameraUI.state = "VideoCapture" } VideoCaptureControls { id: videoControls anchors.fill: parent camera: camera visible: cameraUI.state == "VideoCapture" onPreviewSelected: cameraUI.state = "VideoPreview" onPhotoModeSelected: cameraUI.state = "PhotoCapture" } } QZXing{ id: decoder enabledDecoders: QZXing.DecoderFormat_QR_CODE onDecodingStarted: console.log("Decoding of image started...") onTagFound: { messaggioBarcode.text = tag //console.log("Barcode data: " + tag) messaggioBarcode.open() } onDecodingFinished: console.log("Decoding finished " + (succeeded==true ? "successfully" : "unsuccessfully") ) } MessageDialog{ id: messaggioBarcode title: "BARCODE" text: "testo da cambiare" //buttons: MessageDialog.OK } }
-
what is MainBarcode ?