Results 1 to 5 of 5

Thread: emit not working in constructor

  1. #1
    Join Date
    Nov 2014
    Posts
    23
    Thanks
    4

    Post emit not working in constructor

    Consider the scenario:
    I have 3 CLASS. 1st and 2nd CLASS can be accessed via 3rd CLASS..So i place a connect() inside 3rd CLASS connecting 1st CLASS signal() to 2nd CLASS slot().....But if i place my emit signal in 1st CLASS constructor, its not hitting the slot in 2nd CLASS....But in 1st CLASS, if i place a timer and in its timeout() i emit the signal then appropriate slot is called in 2nd CLASS...

    I need to know the reason why emit is not valid inside 1st CLASS constructor....

    NOTE: 2nd CLASS object is created before 1st CLASS..So there should not have been a problem with calling emit() from 1st CLASS constructor....
    Last edited by vinothrajendran; 11th December 2014 at 11:49. Reason: updated contents

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: emit not working in constructor

    Show the code : crystal ball does not work.
    PS.
    To connect the signal to the slot you first need to create a sender and receiver objects. Thus, the emission signal in the constructor of the sender does not make any sense.

  3. #3
    Join Date
    Feb 2014
    Posts
    60
    Thanks
    4
    Thanked 5 Times in 5 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: emit not working in constructor

    Its simple CLASS1 is not created when signal is emitted.Since you have given in constructor of CLASS1 it will not work.
    Last edited by anbu01; 11th December 2014 at 12:10.

  4. #4
    Join Date
    Nov 2014
    Posts
    23
    Thanks
    4

    Default Re: emit not working in constructor

    Thank for the reply....I got it now.........
    Last edited by vinothrajendran; 11th December 2014 at 12:16.

  5. #5
    Join Date
    Jan 2020
    Posts
    2
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Post Re: emit not working in constructor

    Quote Originally Posted by vinothrajendran View Post
    Consider the scenario:
    I have 3 CLASS. 1st and 2nd CLASS can be accessed via 3rd CLASS..So i place a connect() inside 3rd CLASS connecting 1st CLASS signal() to 2nd CLASS slot().....But if i place my emit signal in 1st CLASS constructor, its not hitting the slot in 2nd CLASS....But in 1st CLASS, if i place a timer and in its timeout() i emit the signal then appropriate slot is called in 2nd CLASS...

    I need to know the reason why emit is not valid inside 1st CLASS constructor....

    NOTE: 2nd CLASS object is created before 1st CLASS..So there should not have been a problem with calling emit() from 1st CLASS constructor....
    see example *URL removed by moderator*
    Last edited by d_stranz; 26th July 2021 at 16:34. Reason: removed URL

Similar Threads

  1. Replies: 7
    Last Post: 24th September 2012, 08:17
  2. Replies: 2
    Last Post: 13th March 2012, 06:26
  3. what does the constructor do here?
    By LB4229 in forum Qt Programming
    Replies: 7
    Last Post: 22nd June 2011, 04:19
  4. Replies: 13
    Last Post: 19th June 2011, 22:04
  5. class constructor
    By ^NyAw^ in forum Qt Programming
    Replies: 2
    Last Post: 5th December 2008, 19:25

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.