I am trying to use QNetworkAccessManger to upload a file and show progress. I have the upload portion working excellently. I cannot seem to get the Progress portion working.

I have a QML ProgressBar on one screen of my mobile app. I tried setting up a Signal like so:

Qt Code:
  1. QNetworkAccessManager *manager = new QNetworkAccessManager(this); //using qnetwork access manager for post data
  2. QObject *root = engine.rootObjects().first();
  3. root->setProperty("networkAccess",manager);
  4.  
  5. manager->post(req,datas); //send all data
  6. connect(manager,SIGNAL(finished(QNetworkReply*)),this,SLOT(erroron_filesend(QNetworkReply*)));
  7. connect(manager, SIGNAL(uploadProgress(qint64 uplPart, qint64 uplTotal)), SLOT(progressChanged(qint64 uplPart, qint64 uplTotal)));
To copy to clipboard, switch view to plain text mode 

In my main.qml, tried to declare a local variant to hold a reference to the Manager:

Qt Code:
  1. property variant networkAccess
To copy to clipboard, switch view to plain text mode 

Then in the QML with the ProgressBar I did this:

Qt Code:
  1. ProgressBar {
  2. id: fileUplProgress
  3. visible: false
  4. anchors.top: busyLabel.bottom
  5. anchors.topMargin: Funcs.psize(10,parent.height)
  6. anchors.horizontalCenter: parent.horizontalCenter
  7. width: Funcs.psize(50,parent.width)
  8. height: Funcs.psize(5,parent.hight)
  9.  
  10. minimumValue: 0.0
  11. maximumValue: 100.0
  12. }
  13. Connections {
  14. target: appWin.networkAccess
  15. onProgressChanged: {
  16. fileUplProgress.value = 100*uplTotal/uplPart;
  17. console.log(qsTr("Progress %1").arg(100*uplTotal/uplPart);
  18. }
  19. }
To copy to clipboard, switch view to plain text mode 

First error I get is with declaring the variant for the Manager in the qml. I have other variants that hold strings passed from C++, so I know it works.

In short, what is the best way to upload a file in C++ and get the progress in my QML page?

--Sam