Implementing WorkerThread

Now that we know how parsing works in XML, we can see what the implementation of the core of WorkerThread looks like, as follows:

  1. The following code shows the implementation of WorkerThread:
WorkerThread::WorkerThread(QObject* owner){    this->setParent(owner);    mNetManager = new QNetworkAccessManager(this);    connect(mNetManager, &QNetworkAccessManager::finished, this, &WorkerThread::handleNetFinished);}void WorkerThread::run() 
{ 
    QXmlStreamReader xml; 
    QXmlStreamReader::TokenType type; 
    QString fieldName; 
    QString value; 
    QString tag; 
    bool successful = false; 
    bool gotValue = false; 
    QMap<QString, QString> result; 
 
    xml.setDevice(mReply); 
  1. Then, we continue to write our code, and start parsing the XML data by looping through ...

Get Application Development with Qt Creator now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.