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. how to use a class written in javascript to qml ?

how to use a class written in javascript to qml ?

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 3 Posters 1.5k 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.
  • S Offline
    S Offline
    september
    wrote on last edited by
    #1

    what need write for a type spot, to use the class written in javascript ?
    @import QtQuick 1.0
    import "control.js" as ScriptControl

    Item
    {
    property type control: new ScriptControl.Control();@

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      "var"

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • S Offline
        S Offline
        september
        wrote on last edited by
        #3

        on the type of var gives this error "
        (qrc:/tank/tank1.qml:10:14: Expected property type)
        QDeclarativeComponent: Component is not ready
        QGraphicsScene::addItem: cannot add null item"

        1 Reply Last reply
        0
        • JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #4

          "Component is not ready" suggests that it takes time for your component to load. You need to wait until it finishes loading, before assigning it to a variable.

          Do the assignment inside the Component.onCompleted() signal handler. See:

          • http://qt-project.org/doc/qt-5/qml-qtqml-component.html#onCompleted-signal
          • http://qt-project.org/doc/qt-5/qml-var.html#change-notification-semantics

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          1 Reply Last reply
          0
          • C Offline
            C Offline
            chrisadams
            wrote on last edited by
            #5

            The 'var' property type is only available in QtQuick 2.0, not in QtQuick 1.0. (Well, technically, in QtQml 2.0, but yeah.)

            Cheers,
            Chris.

            1 Reply Last reply
            0
            • JKSHJ Offline
              JKSHJ Offline
              JKSH
              Moderators
              wrote on last edited by
              #6

              [quote author="chrisadams" date="1387157603"]The 'var' property type is only available in QtQuick 2.0, not in QtQuick 1.0. (Well, technically, in QtQml 2.0, but yeah.)[/quote]Ah, good catch.

              september, are you able to upgrade to Qt Quick 2? Qt Quick 1 is obsolete now.

              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

              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