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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:49:48+00:00 2026-05-25T23:49:48+00:00

I have 5 classes that interact (maintaining professionally, not author). My problem is that

  • 0

I have 5 classes that interact (maintaining professionally, not author). My problem is that the code that is emitting the signal (there is just one, code below) is never activating the slot (MyWidget::HandleMeasurementChanged). This system has a large degree of complexity. I have tried to reduce that, but think the complexity likely contributes to the problem. There is also a high rate of calls to Observer::notify, but most of these will get filtered out by code that I have not posted here and the Emit calls are fairly rare. If anyone could help point me to why the slot is not getting activated, I’d really appreciate it. It is almost acting like the MyWidget class instance is not processing its event loop. I have had a little success setting the connect type to Direct Connection, but since the emit is in a separate thread and the production code for the slot will update the UI I have ruled that out as a final solution.

class IObserver { public: virtual void notify()=0; };

class ExternalMeasurement { ... };
class Measurement { public: Measurement(ExternalMeasurement source); };

class Observer : public QThread, public IObserver
{
signals:
   void MeasurementChanged(boost::shared_ptr<Measurement> measurement);   
public:
   //called by 3rd party in separate thread
   virtual void notify(ExternalMeasurement measurement)
   {
      _measurement_ = 
           boost::shared_ptr<Measurement>(new Measurement(measurement));
      emit MeasurementChanged(_measurement);
   }
private:
   boost::shared_ptr<Measurement> _measurement_;
};

class MyWidget : public QWidget
{
private:
   Component _component_;
public slots:
   void HandleMeasurementChanged(boost::shared_ptr<Measurement> measurement);
public:
   MyWidget(Component * component_)
};

MyWidget::MyWidget(Component * component_)
{
   _component_ = component_;
   connect(
      _component_->_observer_, 
      MeasurementChanged(boost::shared_ptr<Measurement> measurement),
      this,
      HandleMeasurementChanged(boost::shared_ptr<Measurement> measurement));
}

class Component
{
private:
   QApplication * _application_;
   MyWidget * _widget_;
   Observer * _observer_;
public:
   void MainFunc();
}

void Component::MainFunc()
{
   _observer_ = new Observer();
   ...
   _application_ = new QApplication(...);
   ...
   _widget_ = new MyWidget(...);
   ...
   _widget_->show();
   _application_->exec();
}
  • 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-25T23:49:48+00:00Added an answer on May 25, 2026 at 11:49 pm

    This was referenced in the link that Jeremy added in a comment to my question, but just for clarity:

    The solution was to add:

    qRegisterMetaType<shared_ptr<Measurement> >("shared_ptr<Measurement>");
    

    immediately before the call to connect.

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

Sidebar

Related Questions

I have several classes that conceptually belong to one tier. They have no common
I have classes that store data, and methods to go get data for individual
I have classes that are named exactly the same across different plug-ins that I
I have classes that are needed in both my web service and my server.
I have multiple classes that all derive from a base class, now some of
I have two classes that each need an instance of each other to function.
I have some classes that will do something based on some conditions . The
I have custom classes that I currently instantiate within App.xaml as resources. I want
I have two classes that refer to each other, but obviously the compiler complains.
I have two classes that I would like to merge into a composite. These

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.