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

  • SEARCH
  • Home
  • 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 7578181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:22:16+00:00 2026-05-30T17:22:16+00:00

I have some issues with this: First I create my object and move it

  • 0

I have some issues with this:

First I create my object and move it to a thread:

FileUploader *fileUploader = new FileUploader(fileList_, start, (offset == 0 ? (fileList_.count() - start) : offset));
QThread *fileUploaderThread = new QThread;
fileUploader->moveToThread(fileUploaderThread);

fileUploaderThreads_.append(fileUploaderThread);
fileUploaders_.append(fileUploader); // contains pointers to the objects

connect(fileUploader, SIGNAL(progressChangedAt(int)), model_, SLOT(reportProgressChanged(int)), Qt::QueuedConnection);
connect(fileUploader, SIGNAL(statusChangedAt(int)), model_, SLOT(reportStatusChanged(int)), Qt::QueuedConnection);
connect(fileUploader, SIGNAL(finished()), fileUploaderThread, SLOT(quit()), Qt::QueuedConnection);
connect(fileUploaderThread, SIGNAL(finished()), this, SLOT(checkIfFinished()), Qt::QueuedConnection);

The in the slot checkIfFinished() I wanna go though all the threads and see if they quit.
qDebug() << “one thread done”;

foreach(QThread *thread, fileUploaderThreads_) { // or FileUploader* fileuploader, fileUploaders_ ?
    if(thread && !thread->isFinished()) {

        qDebug() << "not finished " << thread->currentThreadId();

        return; // not done
    }
}

When this is printed out, I only get the main thread Id, not the threads. I tried to print the threads id’s out but with no luck (after they are started ofc).
The reason why I’m doing this I because the person writing “Advanced Qt Programming – Mark S” did a similar thing with QThreads that he placed in a list and checked if they where finished. The only thing thats working now is the connection which kills the thread when the fileUploader is done.

Also, how do I store pointers for the threads? I wounder how I will be able to delete them all if they don’t seem to point to the right threads.

Edit:

I tried to store the QObjects in a list instead and do this:

QThread *senderx = qobject_cast<QThread*>(sender());

qDebug() << "one thread done" << senderx;

foreach(FileUploader *fileUploader, fileUploaders_) {
    if(fileUploader && !fileUploader->thread()->isFinished()) {

        qDebug() << "not finished " << fileUploader->thread();

        return; // not done
    }
}
//done 
qDebug() << "done";
setButtonState(false);

And my outprint on the last call is :

one thread done QThread(0x43ee180)

not finished QThread(0x43ee180)

How is this possible? It is done, but the method says otherwise.

  • 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-30T17:22:18+00:00Added an answer on May 30, 2026 at 5:22 pm

    you want QObject::thread(), not QThread::currentThreadId() – the second one returns the thread that the function was called in.

    Once you fix that, your pointers will work fine.

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

Sidebar

Related Questions

Building my first SL MVVM application (Silverlight4 RC) and have some issues i don't
I have some issues with the requestLoop methode of the Pyro4.Daemon object. What I
I will start by saying this is the first time I have done anything
We have some issues in our application with skype taking over some of our
I have some issues with a PHP file that is not working properly. The
I'm have some issues adding a class to 2 navigation links on a theme.
I am integrating PayPal in my website But I have some issues in it.
I've just started using NHibernate, and I have some issues that I'm unsure how
In using our TeamCity Continuous Integration server we have uncovered some issues that we
I have been having some issues with LINQ-To-SQL around memory usage. I'm using it

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.