C++ (Qt)void UpdaterInstall::HttpPostRequest() { m_pReply = m_pNetworkManager->get(QNetworkRequest(pDataModel->getHttpLink())); connect(m_pReply, SIGNAL(readyRead()), this, SLOT(slotDownloadUpdates())); QString strFileName=pDataModel->getFileName(); m_pFile = new QFile(strFileName); m_pFile->open(QIODevice::WriteOnly);} void UpdaterInstall::slotDownloadUpdates() { m_downloadedSize+= m_pFile->write(m_pReply->readAll()); QObject * m_pProgressBar = m_pQml->findChild<QObject*>("updaterProgressBar"); m_pProgressBar->setProperty("value", m_downloadedSize); qDebug()<<m_pProgressBar->property("value").toInt()<<" "<<m_pProgressBar->property("maximumValue").toInt(); }
C++ (Qt)void UpdatingProgressState::onEntry(QEvent *) { Worker * pWorker = new Worker; QThread * pThread = new QThread(); pWorker->moveToThread(pThread); connect(pThread, SIGNAL(started()), pWorker, SLOT(slotDummyUpdatingRequest())); connect(pWorker,SIGNAL(sigDummyNextRequestStage()), this, SLOT(slotStageProgressPrint())); pThread->start();} void UpdatingProgressState::slotStageProgressPrint() { QObject * pList = m_pQmlObject->findChild<QObject*>("progressBar"); pList->setProperty("value", m_nProgress++);}
C++ (Qt)void UpdaterInstall::HttpPostRequest() { //GUI updating m_pProgressBar = m_pQml->findChild<QObject*>("updaterProgressBar"); UpdaterUpdateData * pDataModel = m_pDataModel->getModelItem<UpdaterUpdateData>(); m_pProgressBar->setProperty("maximumValue", 1200); m_downloadedSize=0; //Starting download m_pReply = m_pNetworkManager->get(QNetworkRequest(pDataModel->getHttpLink())); connect(m_pReply, SIGNAL(readyRead()), this, SLOT(slotDownloadUpdates())); QString strFileName="C:/Users/Mira/"+pDataModel->getFileName(); m_pFile = new QFile(strFileName); if (QFile::exists(strFileName)) { QFile::remove(strFileName); } m_pFile->open(QIODevice::WriteOnly);} void UpdaterInstall::slotDownloadUpdates() { int nTemp=m_pFile->write(m_pReply->readAll()); m_downloadedSize+=nTemp/10000; m_pProgressBar->setProperty("value", m_downloadedSize);;}