how to use a class written in javascript to qml ?
-
what need write for a type spot, to use the class written in javascript ?
@import QtQuick 1.0
import "control.js" as ScriptControlItem
{
property type control: new ScriptControl.Control();@ -
"var"
-
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" -
"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:
-
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. -
[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.