Qt Forum

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

    Unable to call another qml class

    QML and Qt Quick
    4
    8
    1366
    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

      I am a self learn QML newbie.
      Below is my code
      currently i got 2 error i do not know how to resolve:
      -Type Marquee unavailable
      -module "QtQuick" version 1.0 is not installed.

      My understanding is qml filename is like a C++ class.
      When i call it in another qml file, it is instantiated.
      Why error Marquee unavailable?

      Another issue is i got problem importing QtQuick Particles 2.0 or any other modules. why?

      @
      --------------main.qml-----------------------

      import QtQuick 2.2
      import QtQuick.Controls 1.1

      ApplicationWindow {
      visible: true
      width: 640
      height: 480
      title: qsTr("Hello World")

      Marquee{               //error1
      width: 640
      padding: 2
      anchors.bottom: parent.bottom
      text: "i love you!"
      color: "black"
      textColor: "white"
      }
      

      }
      --------------Marquee.qml-----------------------

      import QtQuick 1.0 //error2

      Rectangle {
      width: parent.width
      height: marqueeText.height + padding
      clip: true

      // text to be displayed by the Marquee
      property string text
      
      // top/bottom text padding
      property int padding : 10
      
      // the font size used by the Marquee
      property int fontSize : 20
      
      // the scrolling animation interval
      property int interval : 100
      
      // the text color
      property color textColor: "black"
      
      Text {
      

      anchors.verticalCenter: parent.verticalCenter
      id: marqueeText
      font.pointSize: fontSize
      color: textColor
      text: parent.text
      x: parent.width
      }

      Timer {
      

      interval: parent.interval
      onTriggered: moveMarquee()
      running: true
      repeat: true
      }

      function moveMarquee()
      {
      

      if(marqueeText.x + marqueeText.width < 0)
      {
      marqueeText.x = marqueeText.parent.width;
      }
      marqueeText.x -= 10;
      }

      }

      @

      1 Reply Last reply Reply Quote 0
      • sierdzio
        sierdzio Moderators last edited by

        Type Marquee is not available, because it contains an error - so the the engine cannot use it. Fix the error, and the component will work.

        And the error is that you are mixing QtQuick 1 and 2, which are not compatible. Change the import in Marquee.qml to import QtQuick 2.2

        (Z(:^

        1 Reply Last reply Reply Quote 0
        • M
          melghawi last edited by

          Please mark as SOLVED. Thank you.

          1 Reply Last reply Reply Quote 0
          • sierdzio
            sierdzio Moderators last edited by

            [quote author="moeg687" date="1420740400"]Please mark as SOLVED. Thank you.[/quote]

            Sorry, but you are not the original poster. Is that another account of yours?

            (Z(:^

            1 Reply Last reply Reply Quote 0
            • M
              melghawi last edited by

              No, but it seems like it is solved so I was just simply asking the author to mark it as solved. I am sorry if I assumed incorrectly.

              1 Reply Last reply Reply Quote 0
              • sierdzio
                sierdzio Moderators last edited by

                Ah, ok then, thank you. Let's wait for OP response, then.

                (Z(:^

                1 Reply Last reply Reply Quote 0
                • O
                  onek24 last edited by

                  [quote author="sierdzio" date="1418806380"]Type Marquee is not available, because it contains an error - so the the engine cannot use it. Fix the error, and the component will work.

                  And the error is that you are mixing QtQuick 1 and 2, which are not compatible. Change the import in Marquee.qml to import QtQuick 2.2[/quote]

                  -I might be wrong but shouldn't he also import Marquee.qml(or the folder which contains the file)?-

                  Nevermind, tested it out, it's not necessary in some circumstances.

                  1 Reply Last reply Reply Quote 0
                  • sierdzio
                    sierdzio Moderators last edited by

                    Current folder is imported by default in QML.

                    (Z(:^

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