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 845131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:23:53+00:00 2026-05-15T06:23:53+00:00

I am working on an application which uploads the content of the file to

  • 0

I am working on an application which uploads the content of the file to server.

To upload the file to server I am using ‘QNetworkAccessManager’ class. Since it works as asynchronous way, I changed it to work as synchronous way by using QEventLoop.

Class FileTransfer
{
Public : 
     QNetworkAccessManager mNetworkManager;
     Void Upload(QNetworkRequest request, QIODevice *data)
     {
           responce = mNetworkManager.put(request, data);
           EventLoop.exec();
           ReadResponce(responce);
      }

      Void Stop()
      {
            responce ->close();
      }
}

In my sample application I have 2 windows. 1st to select the files and 2nd to show the progress.

When user click on upload button in the first window, the 2nd window will be displayed and then I create the FileTransfer object and start uploading.

While uploading the file if user closes the form then in the destructor of the window I call the stop of ‘FileTransfer’ after that I delete the ‘FileTransfer’ object.

But here the Upload() function is not yet completed so it will crash.

Please help me to:
How to wait in ‘stop()‘ function until the Upload() function is completed

  • 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-05-15T06:23:54+00:00Added an answer on May 15, 2026 at 6:23 am

    From what I can see from your code, you’re executing a QEventLoop but you’re not actually connecting its “quit” slot to any signal. Take the below as an example, login is a QHttp – and the code is taken from something different – but the principle applies.

    /* Create the QEventLoop */
    QEventLoop pause;
    /* connect the QHttp.requestFinished() Signal to the QEventLoop.quit() Slot */
    connect(&login, SIGNAL(requestFinished( int, bool )), &pause, SLOT(quit()));
    /* The code that will run during the QEventLoop */
    login.request(header,&logmein,&result);
    /* Execute the QEventLoop - it will quit when the above finished due to the connect() */
    pause.exec();
    

    This could be applied to your code, if I’m not mistaken, like this…

    /* connect the signal to the relevant slot */
    connect(&mNetworkManager, SIGNAL(finished( QNetworkReply )), &EventLoop, SLOT(quit()));
    /* Execute the code that will run during QEventLoop */
    responce = mNetworkManager.put(request, data);
    /* Execute the QEventLoop */
    EventLoop.exec();
    

    Apologies if I’ve mistaken your query! I’m only getting to grips with qt again after a break, but I believe this is what you mean! Good luck!

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

Sidebar

Related Questions

I am working on an application which requires file upload and it also requires
Hi i am working on an application in which i need to upload a
Background I'm working on an application which requires user-entered content, and I've decided to
The application I'm working on allows users to upload HTML templates with CSS, which
I am working on a web application which supports file uploading. I am already
I am working on a web application which interacts with TFS. When I upload
I am working on a file management application which parses excel files from the
I am working on a tiny tiny application that just uploads a file to
I am working on a Django application which allows a user to upload files.
I am working on application which needs to be authenticated in different domain. To

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.