Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Qml/c++] ReferenceError: code is not defined
Forum Updated to NodeBB v4.3 + New Features

[Qml/c++] ReferenceError: code is not defined

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 824 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.
  • Nio74N Offline
    Nio74N Offline
    Nio74
    wrote on last edited by Nio74
    #1

    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.0

    Item
    {
    id: element

    Backend {
        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.cpp

    
    int 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:
    0_1552716380509_Cattura.JPG

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

      Show where you declared the signals and it's argument ?

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

      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