harikrishnanel
13th November 2014, 14:55
Hi,
I am new to QML. I am writing specific information alone from QML to XML. My main QML file is "Main.qml" and the root refers to "Clock.qml".
After loading the QML, i am fetching the children from the root "Clock".
QObjectList listOfChildren = rootObj->children();
This list contains following child and its object name are:
"ClockImgae1"
"ClockImgae2"
"ClockImgae3"
"ClockImgae4"
"ClockText"
"RootText"
But I want to get only the child object of Clock in Main.qml (i.e., object related to "RootText") and write its objectName in XML.
I didn't find a way to do that. Please help.
Thanks in Advance.
Regards,
Hari Krishnan EL
//---------------------------------------------------
//---------------------------------------------------
//Main.qml
import QtQuick 2.0
Clock {
hours: 10
minutes: 10
Text {
id: cityLabel1; font.bold: true; font.pixelSize: 14; y:200; color: "white"
objectName: "RootText"
}
}
//---------------------------------------------------
//---------------------------------------------------
//Clock.qml
import QtQuick 2.0
Rectangle {
id: clock
width: 200; height: 200; color: "gray"
property alias city: cityLabel.text
property variant hours
property variant minutes
property variant shift : 0
Image { id: background; source: "clock.png"; objectName: "ClockImgae1"}
Image {
x: 92.5; y: 27
source: "hour.png"
objectName: "ClockImgae2"
transform: Rotation {
id: hourRotation
origin.x: 7.5; origin.y: 73;
angle: (clock.hours * 30) + (clock.minutes * 0.5)
Behavior on angle {
SpringAnimation{ spring: 2; damping: 0.2; modulus: 360 }
}
}
}
Image {
x: 93.5; y: 17
source: "minute.png"
objectName: "ClockImgae3"
transform: Rotation {
id: minuteRotation
origin.x: 6.5; origin.y: 83;
angle: clock.minutes * 6
Behavior on angle {
SpringAnimation{ spring: 2; damping: 0.2; modulus: 360 }
}
}
}
Image {
anchors.centerIn: background; source: "center.png"; objectName: "ClockImgae4"
}
Text {
id: cityLabel; font.bold: true; font.pixelSize: 14; y:200; color: "white"
anchors.horizontalCenter: parent.horizontalCenter
objectName: "ClockText"
}
}
//---------------------------------------------------
//---------------------------------------------------
I am new to QML. I am writing specific information alone from QML to XML. My main QML file is "Main.qml" and the root refers to "Clock.qml".
After loading the QML, i am fetching the children from the root "Clock".
QObjectList listOfChildren = rootObj->children();
This list contains following child and its object name are:
"ClockImgae1"
"ClockImgae2"
"ClockImgae3"
"ClockImgae4"
"ClockText"
"RootText"
But I want to get only the child object of Clock in Main.qml (i.e., object related to "RootText") and write its objectName in XML.
I didn't find a way to do that. Please help.
Thanks in Advance.
Regards,
Hari Krishnan EL
//---------------------------------------------------
//---------------------------------------------------
//Main.qml
import QtQuick 2.0
Clock {
hours: 10
minutes: 10
Text {
id: cityLabel1; font.bold: true; font.pixelSize: 14; y:200; color: "white"
objectName: "RootText"
}
}
//---------------------------------------------------
//---------------------------------------------------
//Clock.qml
import QtQuick 2.0
Rectangle {
id: clock
width: 200; height: 200; color: "gray"
property alias city: cityLabel.text
property variant hours
property variant minutes
property variant shift : 0
Image { id: background; source: "clock.png"; objectName: "ClockImgae1"}
Image {
x: 92.5; y: 27
source: "hour.png"
objectName: "ClockImgae2"
transform: Rotation {
id: hourRotation
origin.x: 7.5; origin.y: 73;
angle: (clock.hours * 30) + (clock.minutes * 0.5)
Behavior on angle {
SpringAnimation{ spring: 2; damping: 0.2; modulus: 360 }
}
}
}
Image {
x: 93.5; y: 17
source: "minute.png"
objectName: "ClockImgae3"
transform: Rotation {
id: minuteRotation
origin.x: 6.5; origin.y: 83;
angle: clock.minutes * 6
Behavior on angle {
SpringAnimation{ spring: 2; damping: 0.2; modulus: 360 }
}
}
}
Image {
anchors.centerIn: background; source: "center.png"; objectName: "ClockImgae4"
}
Text {
id: cityLabel; font.bold: true; font.pixelSize: 14; y:200; color: "white"
anchors.horizontalCenter: parent.horizontalCenter
objectName: "ClockText"
}
}
//---------------------------------------------------
//---------------------------------------------------