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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:27:04+00:00 2026-06-18T17:27:04+00:00

I have a multithreaded program that downloads and gets information from a website, then

  • 0

I have a multithreaded program that downloads and gets information from a website, then takes the info, creates a object that i then add to my GridLayout with a image.

I have thousands of objects that i need created and then added to my gridlayout, using 8 threads to get the information and those same 8 threads then create the objects and add them to 8 different grids.

After the program runs for about 20 seconds, i get a
QThread::start: Failed to create thread (The access code is invalid.) errors.
After another few more seconds i get some Runtime C++ Errors that hang and don’t display a message.
What does this imply?
What confuses me, is that at this point, my threads are already created and im not actually creating more threads.. inside those threads though they are each creating Widget Objects and then im sending those to the Main Gridlayout..

I checked the amount of threads i have running (QThread:idealThreadCount) which returns only 8.

I’m multithreading to download the information from the sites, which then each records returns values back which i created into a Object to put into my GridLayout.

Im thinking because at that point, these objects all belong to the single thread, and not ever emit(finished()) until all urls are done, so its hogging something and causing this error?

Should i try MoveToThread and send all these objects back to the Main thread after the information is downladed and the new object is added to my gridlayout?

Does any of this make sense of what is happening, and if do you want me to post the code?

Thanks.

Edit:

Just tried moving the threads after creation, but learnt
QObject::moveToThread: Widgets cannot be moved to a new thread

Here is my creation of threads

void checkNewArrivals::createWorkers(QString url, QString category, QString subCategory){
    QThread* thread = new QThread;
    checkNewArrivalWorker* worker = new checkNewArrivalWorker(url, category, subCategory);
    worker->moveToThread(thread);
    connect(worker, SIGNAL(error(QString)), this, SLOT(errorString(QString)));
    connect(thread, SIGNAL(started()), worker, SLOT(process()));
    connect(worker, SIGNAL(finished()), thread, SLOT(quit()));
    connect(worker, SIGNAL(result(QString,QString,QString,QString,QString,int, int)), this, SLOT(addItem(QString,QString,QString,QString,QString,int, int)));
    connect(worker, SIGNAL(finished()), worker, SLOT(deleteLater()));
    connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
    thread->start();
}

Here is my worker class function that emits the results

void checkNewArrivalWorker::getHtml(QString url){
    html = QString::fromStdString(Curl->getWebsiteHtml(url.toStdString()));
    html = html.mid(html.indexOf("Goods List"));
    html = html.mid(0, html.indexOf("footer"));

    for (int i = 0; i < html.count("GoodsBox"); i++){
        //blah blah blah blah


        emit result(idLink, picLink, price, category, subCategory, row, col);
        col++;
        if (col == 5){
            col = 0;
            row++;
        }

        html = html.replace(itemRow, "");
    }
}

Then i add the results to create a item and add it to a gridlayout

void checkNewArrivals::addToGrid(QGridLayout *layout, QString id, QString picUrl, QString usPrice, int row, int col){
    checkNewArrivalItem* item = new checkNewArrivalItem;
    if (item->setupItem(id, picUrl, usPrice) == true){
        layout->addWidget(item, row, col);
    };
}

These items work fine, until a overload of items i think.. not too sure why im getting this error.

  • 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-18T17:27:06+00:00Added an answer on June 18, 2026 at 5:27 pm

    Qt GUI objects cannot exist in any thread other than the main thread. The GUI objects need to be created and added to the layout in the main thread. You can still gather data from background threads, but you’ll need to pass it back to the main thread for display. For that, I recommend using signals, as signal/slot connections are thread-safe by default.

    Edit: Your new threading looks like it should work. However, I think you’d find it preferable to keep a specific number of threads running and delegate the work to them. For one, creating, starting, stopping and destroying threads is an expensive process. But more importantly, perhaps, is that you might just be creating too many threads.

    Just to be really clear, QThread::idealThreadCount() is not the number of threads you have running, but is the number of threads your CPU can most efficiently handle. I’m guessing you have a quad-core CPU with hyperthreading, making it 8.

    I think it’s most likely that you’re creating too many threads. This sounds a lot like the time when I mistakenly did that.

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

Sidebar

Related Questions

I have a large multithreaded C# program in development that loads multiple DLLs from
I have a multithreaded program where I create a generator function and then pass
I have a multithreaded program that's supposed to run 24/7, sometimes I would see
I have a multithreaded openCV program that uses 4 threads to do the following:
I have a multithreaded java program that runs on Amazon's EC2. It queries and
I have a program that gets a KERN_PROTECTION_FAILURE with EXC_BAD_ACCESS in a very strange
I have a written a MATLAB program that creates custom MATLAB functions on the
I have a multithreaded server C++ program that uses MSXML6 and continuously parses XML
Let's say I have a multithreaded C++ program that handles requests in the form
I am writing a multithreaded program and I have a method that has a

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.