[SOLVED]showing a Random words and sentences in a QML
-
i want to show random words and sentences in my QML,
@import QtQuick 1.0
import "random.js" as RandomRectangle {
width: 360
height: 360Text { id: display x: 76 y: 110 text: Random.randomBg(); anchors.verticalCenterOffset: -63 anchors.horizontalCenterOffset: -77 wrapMode: Text.WrapAtWordBoundaryOrAnywhere anchors.centerIn: parent } MouseArea { id: mouse_area1 x: 222 y: 297 width: 100 height: 42 drag.minimumY: -1000 drag.minimumX: -1000 drag.maximumY: 1000 drag.maximumX: 1000 onClicked: { } }
}
@this is my QML and i want to show my random words to my text element but it says Unable to assign QVariantList to QString, how can i show them??
@
//Here is my js file
function randomBg(){
var hex1=new Array('We Stand Alone Together!!', 'Ayaw', 'Gumana', 'Weaklings!')
var hex2=new Array("Currahee!!")
var hex3=new Array("Band of Brothers")
var hex4=new Array("As I Lay Dying")
var hex5=new Array("Heroes are all Brave")
var hex6=new Array("Astig!")
var bg=[Math.floor(hex1.length*Math.random())]
return bg
}
@ -
i changed my js file and works but it only shows the last word in my hex1, it doesnt change
@function randomBg()
{
var hex1=new Array("We Stand Alone Together!!", "Ayaw", "Gumana", "Weaklings!")var bg=hex1[Math.floor(hex1.length*Math.random())]
return bg
}
@