Results 1 to 10 of 10

Thread: Query in Reading QML file

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2014
    Posts
    4
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Question Query in Reading QML file

    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

    Qt Code:
    1. //---------------------------------------------------
    2. //---------------------------------------------------
    3. //Main.qml
    4. import QtQuick 2.0
    5. Clock {
    6.  
    7. hours: 10
    8. minutes: 10
    9. Text {
    10. id: cityLabel1; font.bold: true; font.pixelSize: 14; y:200; color: "white"
    11. objectName: "RootText"
    12. }
    13.  
    14. }
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. //---------------------------------------------------
    2. //---------------------------------------------------
    3.  
    4. //Clock.qml
    5. import QtQuick 2.0
    6.  
    7. Rectangle {
    8. id: clock
    9. width: 200; height: 200; color: "gray"
    10.  
    11. property alias city: cityLabel.text
    12. property variant hours
    13. property variant minutes
    14. property variant shift : 0
    15.  
    16. Image { id: background; source: "clock.png"; objectName: "ClockImgae1"}
    17.  
    18. Image {
    19. x: 92.5; y: 27
    20. source: "hour.png"
    21. objectName: "ClockImgae2"
    22. transform: Rotation {
    23. id: hourRotation
    24. origin.x: 7.5; origin.y: 73;
    25. angle: (clock.hours * 30) + (clock.minutes * 0.5)
    26. Behavior on angle {
    27. SpringAnimation{ spring: 2; damping: 0.2; modulus: 360 }
    28. }
    29. }
    30. }
    31.  
    32. Image {
    33. x: 93.5; y: 17
    34. source: "minute.png"
    35. objectName: "ClockImgae3"
    36. transform: Rotation {
    37. id: minuteRotation
    38. origin.x: 6.5; origin.y: 83;
    39. angle: clock.minutes * 6
    40. Behavior on angle {
    41. SpringAnimation{ spring: 2; damping: 0.2; modulus: 360 }
    42. }
    43. }
    44. }
    45.  
    46. Image {
    47. anchors.centerIn: background; source: "center.png"; objectName: "ClockImgae4"
    48. }
    49.  
    50. Text {
    51. id: cityLabel; font.bold: true; font.pixelSize: 14; y:200; color: "white"
    52. anchors.horizontalCenter: parent.horizontalCenter
    53. objectName: "ClockText"
    54. }
    55. }
    56. //---------------------------------------------------
    57. //---------------------------------------------------
    To copy to clipboard, switch view to plain text mode 
    Last edited by anda_skoa; 13th November 2014 at 14:52. Reason: missing [code] tags

Similar Threads

  1. reading pdf file
    By kito in forum Newbie
    Replies: 8
    Last Post: 23rd June 2012, 08:17
  2. problem with using xpath to query from xml file
    By aya_lawliet in forum Qt Quick
    Replies: 0
    Last Post: 7th September 2011, 15:38
  3. Reading XML file into a data file correctly?
    By falconium in forum Qt Programming
    Replies: 3
    Last Post: 9th May 2011, 18:55
  4. Execute a .sql file with more than one query
    By ShadowBelmolve in forum Newbie
    Replies: 6
    Last Post: 19th August 2010, 16:48
  5. How to query data by id in a text file
    By SamSong in forum Qt Programming
    Replies: 4
    Last Post: 26th May 2009, 10:58

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.