Hi ,

I am new to QML, please pardon me if its a very obvious question.

I have created a progress bar element using QML and i am able to update the value of the progress bar by the following code.

Qt Code:
  1. QDeclarativeView* progressView = new QDeclarativeView;
  2. progressView->setSource(QUrl("Progressbar.qml"));
  3. setCentralWidget(progressView);
  4.  
  5. QObject *rootObject = dynamic_cast<QObject *>(progressView->rootObject());
  6. QObject *progressQml = rootObject->findChild<QObject *>(QString("progressBar")); //progressBar is the name of the progressbar object.
  7. image->setProperty("value", 99);
To copy to clipboard, switch view to plain text mode 

The issue is, I am not able to update the view if i load the "Progressbar.qml" from another file "Main.qml" using the loader functionality. Code with issue is as follows.

Qt Code:
  1. QDeclarativeView* mainView = new QDeclarativeView;
  2. mainView->setSource(QUrl("main.qml"));
  3. setCentralWidget(mainView);
  4.  
  5. QDeclarativeView* progressView = new QDeclarativeView;
  6. progressView->setSource(QUrl("Progressbar.qml"));
  7. QObject *rootObject = dynamic_cast<QObject *>(progressView->rootObject());
  8. QObject *progressQml = rootObject->findChild<QObject *>(QString("progressBar"));
  9. image->setProperty("value", 99);
To copy to clipboard, switch view to plain text mode 

The main.qml file contents are as follwos.

Qt Code:
  1. import QtQuick 1.0
  2.  
  3. Rectangle {
  4. id: rect
  5. width: 400; height: 400
  6. color: "yellow"
  7.  
  8. Loader {
  9. id:someLoader
  10. }
  11.  
  12. MouseArea {
  13. anchors.fill: parent
  14. onClicked: {
  15. someLoader.source = "Progressbar.qml"
  16. }
  17. }
  18. }
To copy to clipboard, switch view to plain text mode 

Please let me know how i can overcome this problem.