Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Cannot assign to non-existent property in another qml file

    QML and Qt Quick
    3
    5
    10158
    Loading More Posts
    • 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.
    • H
      houmingc last edited by

      error is Cannot assign to non-existent property "marqueeText"
      i believe a qml file can call another qml by its filename but i got an error. Please enlighten

      @
      ===============marqueeText.qml==================================
      import QtQuick 2.0

      Rectangle {

          id:marqueeText
          height: scrollingText.height
          clip: true
          property int tempX: marqueeText.width
          property alias text: scrollingText.text
          Text {
              x: tempX
              id:scrollingText
              color: "Yellow" /* Hard code text color for now */
              font.pixelSize: marqueeText.height - 6;
          }
          Timer {
              id:timer
              interval: 200; running: true; repeat: true
              onTriggered:{
                  tempX = tempX - 5
                  scrollingText.x = tempX;
                  console.debug("Tempx"+ tempX + "TextWidth = " + scrollingText.width, " Height = " + marqueeText.height)
      
                  if( tempX < -scrollingText.width) {
                      tempX = marqueeText.width;
                      console.debug("Restartlling Text")
                  }
                 }
          }
      

      }
      @
      =========main.qml============================
      @
      import QtQuick 2.2
      import QtQuick.Window 2.1
      import QtQuick.Layouts 1.1
      import QtMultimedia 5.0

      Rectangle {
      width: 100
      height: 620
      id: screen

      Grid {
          columns: 2
          spacing: 0
      
          Rectangle {
              id: video;
              color: "black";
              width: 600;
              height: 432
              Video {
                  id: videofile
                  //playing: true
                  source: "video/Bear.wmv"
                  width: 600
                  height: 432
                  opacity: 0.9
                  focus: true
                  onStopped: {
                      videofile.play()
                  }
              }
          }
          Rectangle {
              id: picture; width: 200; height: 432
              anchors.left: video.right
              Image {
                  source: "pic/phone.jpg"
              }
          }
          Rectangle {
              id: text
              width: 800; height: 48
              color: "blue"
              marqueeText {                       //error
                  id:scrolltext
                  width: 800
                  height: 48
                  text: "Qt Quick Digital Signage Demo"
              }
          }
      

      }
      }

      @

      1 Reply Last reply Reply Quote 0
      • D
        dvb0222 last edited by

        Start the class name with an uppercase letter.

        I know, pretty non-intuitive.


        David Van Beveren
        Oak Park Technology Corp.
        Malibu, California
        vbdavid@gmail.com

        1 Reply Last reply Reply Quote 1
        • H
          houmingc last edited by

          you mean id to cap(MarqueeText) or filename & caller in main to cap

          1 Reply Last reply Reply Quote 0
          • D
            dvb0222 last edited by

            All three need to start with a cap.


            David Van Beveren
            Oak Park Technology Corp.
            Malibu, California
            vbdavid@gmail.com

            1 Reply Last reply Reply Quote 0
            • D
              David Stiel last edited by

              You have probably already noticed that the id in marqueeText.qml should not start with an upper case letter as described "here":http://doc.qt.io/qt-5/qtqml-syntax-objectattributes.html#the-id-attribute

              I main.qml you do
              @
              MarqueeText {
              id:scrolltext
              width: 800
              height: 48
              text: "Qt Quick Digital Signage Demo"
              }
              @

              This allocates a new instance of the MarqueeText class/element and has nothing to do with the id you provided in the MarqueeText.qml file

              1 Reply Last reply Reply Quote 0
              • First post
                Last post