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. Component problems
Qt 6.11 is out! See what's new in the release blog

Component problems

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 2 Posters 696 Views 1 Watching
  • 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.
  • C Offline
    C Offline
    Circuits
    wrote on last edited by aha_1980
    #1

    I have a function defined in main.qml:

    function showNumericKeyboard(objectName, modelButtons, primaryIndex, settingValue, hintMsg, accepted)
        {
             var comp = Qt.createComponent("qrc:/WizardPopupNumericKeyboard.qml");
             comp.createObject(application, {
                                  "objectName": objectName
                                  , "modelButtons": modelButtons
                                  , "primaryIndex": primaryIndex
                                  , "settingValue": settingValue
                                  , "hintMsg": hintMsg
                                  , "accepted": accepted
                              })
        }
    

    I call the function like this:

          MouseArea
          {
            anchors.fill: parent
            onClicked:
            {
              showNumericKeyboard("systemDialog", [qsTr("Cancel"), qsTr("Finished")], 1, modelData, qsTr(""), theBool);
    
            }
          }
    

    in PopupNumericKeyboard.qml I try to edit the value of accepted and I get an error:

    Error: Invalid write to global property "accepted"

    what am I doing wrong?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Try renaming your accepted parameter, it apparently clashes with some global property you have made (or maybe it's built-in but I doubt it).

      (Z(:^

      C 1 Reply Last reply
      4
      • sierdzioS sierdzio

        Try renaming your accepted parameter, it apparently clashes with some global property you have made (or maybe it's built-in but I doubt it).

        C Offline
        C Offline
        Circuits
        wrote on last edited by Circuits
        #3

        @sierdzio Interesting, now it's giving me an entirely different error after changing the name:

        ReferenceError: theValue is not defined

        it seems odd because I am printing out hintMsg which I set the text to be "Hint Message" just before and it prints just fine:

        Component.onCompleted
        {
          console.info(hintMsg)
          console.info(theValue)
        }
        

        output:

        qml: Hint Message
        qrc:/WizardPopupNumericKeyboard.qml:21: ReferenceError: theValue is not defined
        
        1 Reply Last reply
        0
        • C Offline
          C Offline
          Circuits
          wrote on last edited by
          #4

          I am not sure what this means, I am very confused. I swapped some things around:

          function showNumericKeyboard(objectName, modelButtons, primaryIndex, settingValue, theValue, hintMsg)
              {
                   var comp = Qt.createComponent("qrc:/WizardPopupNumericKeyboard.qml");
                   comp.createObject(application, {
                                        "objectName": objectName
                                        , "modelButtons": modelButtons
                                        , "primaryIndex": primaryIndex
                                        , "settingValue": settingValue
                                        , "theValue": theValue
                                        , "hintMsg": hintMsg
                                    })
              }
          
          showNumericKeyboard("systemDialog", [qsTr("Cancel"), qsTr("Finished")], 1, modelData, qsTr("Hint Message"), itIsABool);
          
          Component.onCompleted:
            {
              console.info(hintMsg)
              console.info(theValue)
            }
          

          output:

          qml: false
          qrc:/WizardPopupNumericKeyboard.qml:21: ReferenceError: theValue is not defined
          
          1 Reply Last reply
          0
          • C Offline
            C Offline
            Circuits
            wrote on last edited by
            #5

            Apparently I had to define the bool value within WizardPopupNumericKeyboard.qml ? Not sure why but as soon as I instantiated it there as a property:

            property bool theBool: bool

            then it worked:

              Component.onCompleted:
              {
                console.info(hintMsg)
                console.info(theBool)
              }
            

            output:

            qml: Hint Message
            qml: false

            1 Reply Last reply
            1

            • Login

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