PDA

View Full Version : Accessing data of .qml file



jeff28
29th August 2012, 15:07
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):




viewer.setSource(QUrl::fromLocalFile("main.qml")); // viewer is a QDeclarativeView object
viewer.show();
QObject *object = viewer.rootObject();
QObject *test = object->findChild<QObject*>("positionSlider");



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:



// Position Slider
Slider {
id: positionSlider
x: 25
y: 454
value: 0
xMax:360
minimum:-180
maximum:180
}

spirit
29th August 2012, 16:15
Did you try an example described here (http://qt-project.org/doc/qt-4.8/qtbinding.html#locating-child-objects)?