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. Unable to call another qml class
Forum Updated to NodeBB v4.3 + New Features

Unable to call another qml class

Scheduled Pinned Locked Moved QML and Qt Quick
8 Posts 4 Posters 1.7k 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.
  • H Offline
    H Offline
    houmingc
    wrote on 17 Dec 2014, 07:17 last edited by
    #1

    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
    0
    • S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 17 Dec 2014, 08:53 last edited by
      #2

      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
      0
      • M Offline
        M Offline
        melghawi
        wrote on 8 Jan 2015, 18:06 last edited by
        #3

        Please mark as SOLVED. Thank you.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sierdzio
          Moderators
          wrote on 8 Jan 2015, 18:34 last edited by
          #4

          [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
          0
          • M Offline
            M Offline
            melghawi
            wrote on 8 Jan 2015, 19:23 last edited by
            #5

            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
            0
            • S Offline
              S Offline
              sierdzio
              Moderators
              wrote on 9 Jan 2015, 12:55 last edited by
              #6

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

              (Z(:^

              1 Reply Last reply
              0
              • O Offline
                O Offline
                onek24
                wrote on 9 Jan 2015, 13:40 last edited by
                #7

                [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
                0
                • S Offline
                  S Offline
                  sierdzio
                  Moderators
                  wrote on 12 Jan 2015, 09:06 last edited by
                  #8

                  Current folder is imported by default in QML.

                  (Z(:^

                  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