kunal269
13th November 2010, 08:12
Below is the given code snippet of the qml file which is loaded through a cpp file of a qt project. In this i want to directly call a .js file fucntion createGrid to run on PowerCell elements in a loop which are commented to create a grid.
This gives the error: Invalid import for import line of .js file
import Qt 4.7
import "loop.js" as genList
Rectangle {
id:page
width: 550; height:159
x:0
y:0
signal gridEntry
property variant listOfPowerHogs: powerHogList
Image {
id: backGround
source: "ui_images/background.png"
Flickable{
id:flick
anchors.fill: parent
contentWidth: flickArea.width
contentHeight: flickArea.height
flickableDirection: Flickable.HorizontalFlick
Grid{
id:flickArea
x:0
y:12
width: 697
height: 135
rows: 1; columns: 5; spacing: 8;
// PowerCell {
// width:/* page.inPortrait ? (parent.width-4)/2 : (parent.width-8)/3*/ (parent.width-100)/4
// iconValue: listOfPowerHogs[0]
// instrumentedStatus: listOfPowerHogs[1]
// }
// PowerCell {
// width: (parent.width-100)/4
// iconValue: listOfPowerHogs[2]
// instrumentedStatus: listOfPowerHogs[3]
// }
// PowerCell {
// width: (parent.width-100)/4
// iconValue: listOfPowerHogs[4]
// instrumentedStatus: listOfPowerHogs[5]
// }
// PowerCell {
// width: (parent.width-100)/4
// iconValue: listOfPowerHogs[6]
// instrumentedStatus: listOfPowerHogs[7]
// }
genList.createGrid(listOfPowerHogs)
}
states: State {
name: "ShowBars"
when: view.movingVertically || view.movingHorizontally
}
transitions: Transition {
NumberAnimation { properties: "opacity"; duration: 400 }
}
}
ScrollBar {
id: horizontalScrollBar
width: flick.width-12; height: 12
anchors.bottom: flick.bottom
opacity: 0
orientation: Qt.Horizontal
position: flick.visibleArea.xPosition
pageSize: flick.visibleArea.widthRatio
}
}
}
This gives the error: Invalid import for import line of .js file
import Qt 4.7
import "loop.js" as genList
Rectangle {
id:page
width: 550; height:159
x:0
y:0
signal gridEntry
property variant listOfPowerHogs: powerHogList
Image {
id: backGround
source: "ui_images/background.png"
Flickable{
id:flick
anchors.fill: parent
contentWidth: flickArea.width
contentHeight: flickArea.height
flickableDirection: Flickable.HorizontalFlick
Grid{
id:flickArea
x:0
y:12
width: 697
height: 135
rows: 1; columns: 5; spacing: 8;
// PowerCell {
// width:/* page.inPortrait ? (parent.width-4)/2 : (parent.width-8)/3*/ (parent.width-100)/4
// iconValue: listOfPowerHogs[0]
// instrumentedStatus: listOfPowerHogs[1]
// }
// PowerCell {
// width: (parent.width-100)/4
// iconValue: listOfPowerHogs[2]
// instrumentedStatus: listOfPowerHogs[3]
// }
// PowerCell {
// width: (parent.width-100)/4
// iconValue: listOfPowerHogs[4]
// instrumentedStatus: listOfPowerHogs[5]
// }
// PowerCell {
// width: (parent.width-100)/4
// iconValue: listOfPowerHogs[6]
// instrumentedStatus: listOfPowerHogs[7]
// }
genList.createGrid(listOfPowerHogs)
}
states: State {
name: "ShowBars"
when: view.movingVertically || view.movingHorizontally
}
transitions: Transition {
NumberAnimation { properties: "opacity"; duration: 400 }
}
}
ScrollBar {
id: horizontalScrollBar
width: flick.width-12; height: 12
anchors.bottom: flick.bottom
opacity: 0
orientation: Qt.Horizontal
position: flick.visibleArea.xPosition
pageSize: flick.visibleArea.widthRatio
}
}
}