[Qml/c++] ReferenceError: code is not defined
-
Good moorning it give me a error in the row 16: ReferenceError: code is not defined
this is my Riparazioni.qml
import QtQuick 2.10
import QtQuick.Controls 2.3
import io.qt.Backend 1.0Item
{
id: elementBackend { id: backend onSendCode: { console.log( "This is code---> " + code); // errrrrrrrrrorrrrrrrr } } 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: 44 color: "#0e99b2" 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: 50 height: 20 anchors.verticalCenter: parent.verticalCenter anchors.bottom: parent anchors.bottomMargin: 0 anchors.left: lbl_SearchCode.right anchors.leftMargin: 20 } CustomButton { id: btnSearchKey x: 583 y: 3 text: "S" 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.connectClicked() backend.connectClicked() backend.sendClicked(c_Txt_codice.text) } } } } 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: 2 Rectangle{ id: rectangle_Articolo color: "#0e99b2" anchors.fill: parent Label{ id: lbl_NBusta color: "#ebedef" text: "N°Busta" anchors.left: parent.left anchors.leftMargin: 5 anchors.top: parent.top anchors.topMargin: 10 } CustomTextEdit { id: txtCodice width: 40 height: 18 anchors.top: parent.top anchors.topMargin: 10 anchors.left: lbl_NBusta.right anchors.leftMargin: 10 } } }
}
this is my main.cppint main(int argc, char *argv[]) { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); //Pass my c++ to Qml //qmlRegisterType<ClientServices>("io.qt.Clienteservices", 1, 0, "Clientservices"); qmlRegisterType<Backend>("io.qt.Backend", 1, 0, "Backend"); // Backend backend; // QQmlContext *context = engine.rootContext(); // context->setContextProperty("backend",&backend); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); if (engine.rootObjects().isEmpty()) return -1; return app.exec(); }
this is the Signal with send at Riparazioni.qml and I have do the debug it has data:
-
Show where you declared the signals and it's argument ?