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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:45:53+00:00 2026-05-27T02:45:53+00:00

I have a worker QThread in which a QObject derived object is created. The

  • 0

I have a worker QThread in which a QObject derived object is created. The object is an aggregate of two other QObject derived objects, as such there are internal connections for signal linking and binding the two internal objects together.

The worker QThread is a member of a QPlugin, so is present throughout the lifetime of the plugin.

The problem I have is that although the object is interacting fine with the rest of the application, those internal connections seem to be broken. As an experiment I tried creating the object in the main thread and the internal connections are functioning, so it is definitely something I’m doing wrong with QThreads.

I also tried moving the object back to the main thread (admittedly after those internal connections are made), but it had no effect. I cycled through every type of connection (Direct, Queued, etc) for the internal connections, but it either had no effect or triggered deadlock errors. All the types passed through the connections are registered.

The object is the parent QObject of the two contained objects, it shouldn’t make a difference as they all reside in the same thread, but I tried setting their parent to NULL just to rule it out – it had no effect unsurprisingly. The QThread is not a parent to anything.

The only thing I am not certain of is that the object is created from a factory singleton that resides in the main thread, but is called from the worker thread – so who does it belong to? I am at a complete loss as to what I’m doing (or not doing) to break these connections, so any help is greatly appreciated. Here is the code at the relevant parts of the application:

This the object creation call in the worker thread, for context the object is poly mesh from an OBJ importer.

//  Create mesh.
QString type = Sy::plugMeshType + "Sy_polyMesh";
QString name = proj->newNameIncrement( "objMesh" );

Sy::PluginArgs args; args << name;
Sy_polyMesh* obj = Sy_pluginLoader::createInstance< Sy_polyMesh >( type, args );
obj->mesh() = mesh;
obj->resizeBB();
result_ = obj;

//  If in GUI mode, register it with the project.
if ( gui_ ) {
    proj->registerSimObject( obj );
    proj->selectObject( obj );
}

I have quite an extensive plugin architecture to my app, so the actual thread starting code is abstracted into an abstract worker class:

void Sy_abstractLongProcess::begin( Sy_abstractLongProcessWorker* worker )
{
    worker_ = worker;
    worker_->moveToThread( &thread_ );

    QObject::connect( &thread_, SIGNAL( started() ), worker_, SLOT( work() ) );

    QObject* thisObj = dynamic_cast< QObject* >( this );

    QObject::connect( &thread_, SIGNAL( finished() ), worker_, SIGNAL( finished() ) );
    QObject::connect( worker_, SIGNAL( finished() ), thisObj, SIGNAL( finished() ) );
    QObject::connect( worker_, SIGNAL( progressChanged( double ) ), thisObj, SIGNAL( progressChanged( double ) ) );
    QObject::connect( worker_, SIGNAL( finished() ), &thread_, SLOT( quit() ) );

    thread_.start();
}

As all the relevant code is spread across many classes, I won’t list everything (this question is long enough), but if you need to see anything else don’t hesitate to ask – I need all the help I can get on this one.

  • 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-27T02:45:53+00:00Added an answer on May 27, 2026 at 2:45 am

    I almost had the answer in the original post, when I tried to move the object back to the main thread, only I did it too early. I had to move it back once I completed the modifications that needed to be done in the worker thread – seems obvious now!

    Thanks to Mat for putting me on track for working it out

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

Sidebar

Related Questions

I have a C++/Qt QThread worker thread, which stores its current status as an
I have a class 'Downloader' derived from QObject that runs in a worker thread.
I have a background worker which can be cancelled. The normal flows interrupt itself
I have a worker class that does stuff with a collection of objects. I
I have the main (GUI) thread which creates a QThread. In the QThread, I
I have Worker, Manager, and Title models in Rails 2.x. There is also a
In my application there's the main thread and a worker thread ( QThread ).
I have a worker thread, which holds a list of 'Thread Actions', and works
OS is Linux, working with pthreads I have two worker threads that run forever,
I have a worker thread that is listening to a TCP socket for incoming

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.