Results 1 to 2 of 2

Thread: Accessing data of .qml file

  1. #1
    Join Date
    Aug 2012
    Posts
    30
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Accessing data of .qml file

    Hi, I have a .qml file that I am trying to read, for that I have the following lines (from my window.cpp file in the constructor):

    Qt Code:
    1. viewer.setSource(QUrl::fromLocalFile("main.qml")); // viewer is a QDeclarativeView object
    2. viewer.show();
    3. QObject *object = viewer.rootObject();
    4. QObject *test = object->findChild<QObject*>("positionSlider");
    To copy to clipboard, switch view to plain text mode 

    There is an instance called positionSlider in my main qml. I would like to change the value of upper and lower boundaries of this slider from my .cpp file. Can you help me about this please because I don't know how to continue?? Note that in the main.qml code I have entered my own values which is below:

    Qt Code:
    1. // Position Slider
    2. Slider {
    3. id: positionSlider
    4. x: 25
    5. y: 454
    6. value: 0
    7. xMax:360
    8. minimum:-180
    9. maximum:180
    10. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Accessing data of .qml file

    Did you try an example described here?
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

Similar Threads

  1. QTableView : accessing the data
    By marvaneke in forum Newbie
    Replies: 10
    Last Post: 30th March 2012, 11:31
  2. Accessing the first data item from a IndexList.
    By Bonafide in forum Qt Programming
    Replies: 14
    Last Post: 26th February 2010, 04:10
  3. Multiple File Data accessing
    By hasnatzaidi in forum Newbie
    Replies: 1
    Last Post: 28th October 2009, 16:34
  4. Accessing data from a worker thread
    By steg90 in forum Qt Programming
    Replies: 20
    Last Post: 25th May 2007, 10:20
  5. accessing data in a QFile
    By nass in forum Qt Programming
    Replies: 1
    Last Post: 21st September 2006, 16:25

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.