Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. how to connect a signal from other class
Forum Updated to NodeBB v4.3 + New Features

how to connect a signal from other class

Scheduled Pinned Locked Moved Unsolved Game Development
9 Posts 4 Posters 2.8k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    augus250
    wrote on last edited by
    #1

    I have my signal SIGNAL(certificatesPeremptionChanged()) ,

    how is implemented in this class configurationmanager.h,

    I want to associate it with the slot markModified (), which is implemented in embeddedcalibbration.cpp Class.

    therefore, i do like
    My header :
    private:
    const ConfigurationManager *_configurationManager;

    My source :
    EmbeddedCalibration::EmbeddedCalibration(QObject *parent,
    bool offlineSensor,
    bool simulatedSensor) :
    Calibration(offlineSensor || simulatedSensor, true, parent),
    EmbeddedProcessAspect(offlineSensor),_configurationManager(NULL),
    _needSave(false)
    {
    connect(this, SIGNAL(modified()), SLOT(markModified()));
    connect(_configurationManager, SIGNAL(certificatesPeremptionChanged()), SLOT(markModified()));
    }
    connect(_configurationManager, SIGNAL(certificatesPeremptionChanged()), SLOT(markModified()));

    And nothing happen.

    I will appreciate you help.

    Thank you !

    JonBJ 1 Reply Last reply
    0
    • A augus250

      I have my signal SIGNAL(certificatesPeremptionChanged()) ,

      how is implemented in this class configurationmanager.h,

      I want to associate it with the slot markModified (), which is implemented in embeddedcalibbration.cpp Class.

      therefore, i do like
      My header :
      private:
      const ConfigurationManager *_configurationManager;

      My source :
      EmbeddedCalibration::EmbeddedCalibration(QObject *parent,
      bool offlineSensor,
      bool simulatedSensor) :
      Calibration(offlineSensor || simulatedSensor, true, parent),
      EmbeddedProcessAspect(offlineSensor),_configurationManager(NULL),
      _needSave(false)
      {
      connect(this, SIGNAL(modified()), SLOT(markModified()));
      connect(_configurationManager, SIGNAL(certificatesPeremptionChanged()), SLOT(markModified()));
      }
      connect(_configurationManager, SIGNAL(certificatesPeremptionChanged()), SLOT(markModified()));

      And nothing happen.

      I will appreciate you help.

      Thank you !

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by
      #2

      @augus250
      Google for: qt how to connect a signal from other class
      ?
      Lots of hits/examples (e.g. this forum, other forums, stackoverflow...).

      1 Reply Last reply
      1
      • A Offline
        A Offline
        augus250
        wrote on last edited by
        #3

        @JNBarchan I already do it , try to inspire from it but unfortunately, idon't have results.

        JonBJ 1 Reply Last reply
        0
        • A augus250

          @JNBarchan I already do it , try to inspire from it but unfortunately, idon't have results.

          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by
          #4

          @augus250 said in how to connect a signal from other class:

          @JNBarchan I already do it , try to inspire from it but unfortunately, idon't have results.

          You mean you didn't know what to do from the results you read, or you did not find any results? Because it should return you results OK.

          I will be quiet now, and hope someone else will look at your code and offer some specific advice....

          1 Reply Last reply
          0
          • A Offline
            A Offline
            augus250
            wrote on last edited by
            #5

            @JNBarchan my signal doesn't bring any change I mean .

            1 Reply Last reply
            0
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @augus250 said in how to connect a signal from other class:

              _configurationManager(NULL),

              It seems you do not create the class?

              please check your connects that they return true.

              A 1 Reply Last reply
              1
              • Pablo J. RoginaP Offline
                Pablo J. RoginaP Offline
                Pablo J. Rogina
                wrote on last edited by
                #7

                @augus250 when everything fails, please read the user manual :-)

                Seriously, you may want to take a look at the signals & slots documentation, to have a clear understanding about the subject.

                And as a primer about your problem, the key is "Signals and slots are used for communication between objects" so this line:

                connect(this, SIGNAL(modified()), SLOT(markModified()));
                

                is indeed:

                connect(this, SIGNAL(modified()), **OBJECT MISSING!!**, SLOT(markModified()));
                

                Upvote the answer(s) that helped you solve the issue
                Use "Topic Tools" button to mark your post as Solved
                Add screenshots via postimage.org
                Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                A 1 Reply Last reply
                4
                • mrjjM mrjj

                  @augus250 said in how to connect a signal from other class:

                  _configurationManager(NULL),

                  It seems you do not create the class?

                  please check your connects that they return true.

                  A Offline
                  A Offline
                  augus250
                  wrote on last edited by
                  #8

                  @mrjj Yes exacltly my object was null. thank you.

                  So i tried to do this

                  EmbeddedCalibration::EmbeddedCalibration(QObject *parent,
                  bool offlineSensor,
                  bool simulatedSensor,
                  ConfigurationManager *configManager) :
                  Calibration(offlineSensor || simulatedSensor, true, parent),
                  EmbeddedProcessAspect(offlineSensor),
                  _needSave(false), _configManager(configManager)

                  Here it is my prototype :
                  EmbeddedCalibration(QObject *parent=NULL,
                  bool offlineSensor=false,
                  bool simulatedSensor=false, ConfigurationManager *configManager = NULL);

                  {
                  connect(this, SIGNAL(modified()), SLOT(markModified()));
                  connect(_configManager, SIGNAL(certificatesPeremptionChanged()), SLOT(markModified()));
                  DEBUG() << "Configuration manager" <<_configManager;
                  }

                  my object _configManager point to _configManager which is in this class :

                  Lg3Calibration::Lg3Calibration(
                  #ifdef DEVICES_I2C
                  I2c &i2cBus, quint8 i2cEepromSlaveNumber,
                  #else
                  const QString &probeName,
                  #endif
                  const TimeManager *timeManager,
                  const MessageManager *messageManager,
                  ConfigurationManager *configManager,
                  QObject *parent) :
                  EmbeddedCalibration(parent, configManager)

                  As you see I pass EmbeddedCalibration configManager ,

                  I putt the logs and I see that in embedded Calibration _configurationManager is not null but in Lg3Calibration configurationManager is null.

                  DEBUG() << "Configuration manager lg3 calibration" <<_configurationManager;
                  :Lg3Calibration Configuration manager lg3 calibration MasterclaveConfigurationManager(0x2000af0)
                  EmbeddedCalibration::EmbeddedCalibration Configuration manager QObject(0x0)

                  Thank you for your help.

                  1 Reply Last reply
                  0
                  • Pablo J. RoginaP Pablo J. Rogina

                    @augus250 when everything fails, please read the user manual :-)

                    Seriously, you may want to take a look at the signals & slots documentation, to have a clear understanding about the subject.

                    And as a primer about your problem, the key is "Signals and slots are used for communication between objects" so this line:

                    connect(this, SIGNAL(modified()), SLOT(markModified()));
                    

                    is indeed:

                    connect(this, SIGNAL(modified()), **OBJECT MISSING!!**, SLOT(markModified()));
                    
                    A Offline
                    A Offline
                    augus250
                    wrote on last edited by
                    #9

                    @Pablo-J.-Rogina

                    Thank you for your attention,
                    connect(this, SIGNAL(modified()), SLOT(markModified()));

                    is indeed:

                    connect(this, SIGNAL(modified()), OBJECT MISSING!!, SLOT(markModified()));

                    I don't have an object missing at slot , because my slot is in class.
                    I used the logs and I see that the connection happens no problem.

                    The problem now is about that connection;
                    connect(_configManager, SIGNAL(certificatesPeremptionChanged()), SLOT(markModified()));

                    I Can't retrieve my object _configManager

                    Thank you .

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved