[SOLVED]How to Random the show of QML
-
I want to Random the showof QML when a mousearea is clicked
for example i have 5 QML
qml1.qml
qml2.qml
qml3.qml
qml4.qml
qml5.qmland to view them i will use a loader element
@
Loader {
id:mainLoader
{
MouseArea {
id: mouse_area4
x: 35
y: 243
width: 100
height: 17
onClicked: mainLoader.source ="";//the source will choose from the 5 qml
}
}@Im thinking of using js is it possibleto use qml's in an array and Randomized it for viewing?
How can i do this? -
what if i have other qml's and i only want to random is the 5 qml's which is qml1 - qml5
ive created a js file
@function randomqml ()
{
var qml= new Array ("qml1.qml", "qml2.qml", "qml3.qml", "qml4.qml", "qml5.qml")var bg var bg = qml[Math.floor(qml.length*Math.random)] return bg
}
@@onClicked: mainLoader.source = Random.randomqml();
}
@and when i click the mousearea it return an error of Cannot assign [undefined] to QUrl