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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:00:50+00:00 2026-05-23T07:00:50+00:00

I am working on a multithread QT project. The main problem is on a

  • 0

I am working on a multithread QT project. The main problem is on a serial controller class. This class uses QMutex and QWaitCondition to shyncronize write and read methods.

The problem is about a signal blocked in a children class due to qwaitcondition wait method in the parent. Once the wait method returns, the signal in the children class is emmited (the receiver is also the children class).

I think this method (qwaitcondition – wait) is blocking any signal emission in my entire application.

The problem is something like that:

constructor()
{
    anotherclass = new MyClass;
}
void run()
{
   forever
   {
       if(readmethod())
            waitcondition.wakeall();
   }
}

void method1()
{
      sendpacket();
      mutex.lock();
      if(waitcondition.wait(&mutex,10000))
         //somecode;

      mutex.unlock();
}

class MyClass
{
   someObject sobj;
    MyClass()
    {
        connect(sobj,SIGNAL(somesignal),this,SLOT(someslot));
    }

    void someslot()
    {
        //some code
    }
}

My slot called someslot only is called once the qwaitcondition returns due to the timeout (10 seconds in this case).

I just want to use mutex and the qwaitcondition in this class, not in the entire application. I tried to instantiate the children class in the main thread but I got the same behavior.

CONCEPTUAL TEST

I made a test project and I published it at this link:
testwaitconditionproject

the test project works in this way:
A waitcondition is iniated with timeout equal to 10 seconds in the parent thread.
A children thread emit a signal every 2 seconds, an internal slot must emit a signal captured by the parent. Once the parent slot is called, a flag is set to true. This flag should fire a wakeall to finish de waitcondition.

BUT NOT, the children’s internal signals only are fired after the waitcondition timeout. THIS IS MY MAIN PROBLEM, the parent waitcondition is blocking my children’s signals.

EDIT:

I solved the problem in the test project, calling the method with waitcondition in another thread. It is not possible to me to replicate the issue because the asynchronous call to the method occurs in the thread 1 (via dbus). I am wondering the dbus call is emitted in the thread 1, so my events in the children class are not going to be emitted while the instance belongs to the same thread.

EDIT 2:

I solved my problem putting the pparent and the children in an intermediate class qthread. they were instantiated in the run method, and an exec call was used too.

  • 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-23T07:00:51+00:00Added an answer on May 23, 2026 at 7:00 am

    It seems that you don’t run QCoreApplication event loop, which is required to process events. write() called before QCoreApplication::exec() blocks event loop. Moreover, it seems that it’s important to create all QThread objects inside thread which has event loop (if you want to use signals from such objects). I’ve got your example, created additional thread which runs pparent (and unblocks QCoreApplication::exec()), and it works well.

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

Sidebar

Related Questions

I'm working on a multithreaded (pthread based) project. The project uses a library that
I'm trying to write a multithreaded web crawler. My main entry class has the
Working on a project at the moment and we have to implement soft deletion
Working on a project that parses a log of events, and then updates a
Working in Eclipse on a Dynamic Web Project (using Tomcat (v5.5) as the app
New to pthread programming, and stuck on this error when working on a C++&C
I'm working on a graphical application which looks something like this: while (Simulator.simulating) {
I have a project that I have recently started working on seriously but had
I am working on a trace tool for multithread applications, more especially about memory
I have read some tips that multithread implementation largely depends on the target OS

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.