Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8783809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:55:19+00:00 2026-06-13T20:55:19+00:00

I am currently experiencing issues on a Qt thread. I have to upload a

  • 0

I am currently experiencing issues on a Qt thread.

I have to upload a list of files in a QThread, but apparently one upload doesn’t work and/or my slots are never called. If I put the methods out of the thread it works perfectly.

Here is the run() method :

void UploadThread::run()
{
    for (int i = 0; i < Window::_listUpload.size(); i++) {
        qDebug() << Window::_listUpload[i].getPath();
        this->sendFile(Window::_listUpload[i].getPath());
    }
}

Here is the sendFile() method :

void UploadThread::sendFile(const QString & path)
{
    QFreeDesktopMime mime;
    QNetworkAccessManager *manager = new QNetworkAccessManager;
    QFileInfo fInfo(path);
    QNetworkRequest request(QUrl("http://my-url/"));
    QNetworkReply *reply;

    QString bound = "---------------------------723690991551375881941828858";
    QByteArray data(QString("--"+bound+"\r\n").toAscii());
    data += "Content-Disposition: form-data; name=\"action\"\r\n\r\n";
    data += "\r\n";
    data += QString("--" + bound + "\r\n").toAscii();
    data += "Content-Disposition: form-data; name=\"file\"; filename=\""+fInfo.fileName()+"\"\r\n";
    data += "Content-Type: "+mime.fromFile(path)+"\r\n\r\n";

    QFile file(fInfo.absoluteFilePath());
    file.open(QIODevice::ReadOnly);
    data += file.readAll();
    data += "\r\n";
    data += QString("--" + bound + "\r\n").toAscii();
    data += QString("--" + bound + "\r\n").toAscii();
    data += "Content-Disposition: form-data; name=\"desc\"\r\n\r\n";
    data += "Description for my image here :)\r\n";
    data += "\r\n";
    request.setRawHeader(QString("Accept-Encoding").toAscii(), QString("gzip,deflate").toAscii());
    request.setRawHeader(QString("Content-Type").toAscii(),QString("multipart/form-data; boundary=" + bound).toAscii());
    request.setRawHeader(QString("Content-Length").toAscii(), QString::number(data.length()).toAscii());

    reply = manager->post(request, data);

    QObject::connect(reply, SIGNAL(uploadProgress(qint64,qint64)), currentThread(), SLOT(receiveUploadProgress(qint64, qint64)));
    QObject::connect(manager, SIGNAL(finished(QNetworkReply*)), currentThread(), SLOT(uploadFinished(QNetworkReply*)));
}

And here are my slots :

void UploadThread::uploadFinished(QNetworkReply *reply)
{
    _isFinished = true;
}

void UploadThread::receiveUploadProgress(qint64 bytesSent, qint64 bytesTotal)
{
    qDebug() << bytesSent << " " << bytesTotal;
}

Do you see a problem in my code ?
Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T20:55:22+00:00Added an answer on June 13, 2026 at 8:55 pm

    Ok, I get it.

    For each upload, I need to start the QEventLoop using exec(), and at the end of an upload I have to use exit() in order to finish the QEventLoop. It now works like a charm.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently experiencing issues installing the .NET 3.5 framework on my work computer
I'm currently experiencing some problems with my server. I have a pool which is
I'm currently looking at custom developed Web App Solution that is experiencing performance issues
We're currently experiencing issues with database locking using SQLite in a multi-user environment. These
I'm currently experiencing some scrolling issues in a few of my views. The performance
I'm currently experiencing a strange issue that my understanding of SQL server doesn't quite
I am currently experiencing some issues with some touch detection in a plugin i
I'm experiencing some issues with the footer of my website I'd like to have
I have a UITableViewController backed by a NSFetchedResultsController. I'm currently experiencing a SIGABRT when
I am experiencing very weird issues surrounding Images. I have a settings window, which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.