view.qml Example File
multimedia/declarative-radio/view.qml
import QtQuick 2.0
import QtMultimedia 5.0
Rectangle {
anchors.fill: parent
id: root
property int margins: 5
property int spacing: 10
QtObject {
id: d
property int buttonHeight: root.height > root.width ? root.width / 3 : root.height / 3
property int buttonWidth: (root.width - spacing * 4) / 4
}
Radio {
id: radio
band: Radio.FM
}
Column {
anchors.fill: parent
anchors.margins: root.margins
Rectangle {
color: root.color
width: parent.width
height: root.height - d.buttonHeight - 40
Text {
id: freq
verticalAlignment: Text.AlignVCenter
text: "" + radio.frequency / 1000 + " kHz"
anchors {
bottom: parent.bottom
margins: root.margins
}
}
Text {
id: sig
anchors {
bottom: parent.bottom
right: parent.right
margins: root.margins
}
verticalAlignment: Text.AlignVCenter
text: (radio.availability == Radio.Available ? "No Signal " : "No Radio Found")
}
}
Row {
spacing: 5
Rectangle {
width: root.width - 10
height: 20
color: "black"
Rectangle {
width: 5
height: 20
color: "red"
y: 0
x: (parent.width - 5) * ((radio.frequency - radio.minimumFrequency) / (radio.maximumFrequency -
radio.minimumFrequency))
}
}
}
Row {
spacing: root.spacing
Button {
text: "Scan Down"
onClicked: radio.scanDown()
}
Button {
text: "Freq Down"
onClicked: radio.tuneDown()
}
Button {
text: "Freq Up"
onClicked: radio.tuneUp()
}
Button {
text: "Scan Up"
onClicked: radio.scanUp()
}
}
}
}