Results 1 to 4 of 4

Thread: Slot not getting called, Qt::ConnectionType, Thread

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2012
    Posts
    26
    Qt products
    Qt4
    Platforms
    Windows

    Default Slot not getting called, Qt::ConnectionType, Thread

    I have some strange problems with one SIGNAL/SLOT.

    There is one class A::B::Class1 that emits two signals, first without argument, second with one argument.

    Qt Code:
    1. A::B::J param;
    2. emit orange(param); // Not executed
    3. emit blue();
    To copy to clipboard, switch view to plain text mode 

    In A::C::Class2 the signals and slots are connected. Both connections returns true, but only 1 Slot gets executed, that one without any parameter.

    Qt Code:
    1. void V::run()
    2. {
    3. object = new Object();
    4.  
    5. connect(object, SIGNAL(blue()), this, SLOT(blue_exec()));
    6. connect(object, SIGNAL(orange(A::B::J&)), this, SLOT(orange_exec(A::B::J&)));
    7.  
    8. //...
    9.  
    10. exec();
    11. }
    To copy to clipboard, switch view to plain text mode 

    It is definately a problem with the SIGNAL.

    I just did a test with Qt::ConnectionType and a test allocating object on stack with Object object and

    Qt Code:
    1. void V::run()
    2. {
    3. Object object;
    4.  
    5. connect(&object, SIGNAL(orange(A::B::J&)), this, SLOT(orange_exec(A::B::J&)));
    6.  
    7. //...
    8.  
    9. exec();
    10. }
    To copy to clipboard, switch view to plain text mode 

    It works. Same thing, if I use Qt:irectConnection.

    Qt Code:
    1. void V::run()
    2. {
    3. object = new Object();
    4.  
    5. connect(object, SIGNAL(orange(A::B::J&)), this, SLOT(orange_exec(A::B::J&)), Qt::DirectConnection);
    6.  
    7. //...
    8.  
    9. exec();
    10. }
    To copy to clipboard, switch view to plain text mode 

    That doesn't make sense to me. Why the first connection gets executed, while the second does not. Both are using the same "object"?

    Last edited by StarShaper; 7th February 2012 at 04:08.

Similar Threads

  1. Replies: 2
    Last Post: 26th August 2011, 08:51
  2. connect() return value
    By hojoff79 in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2011, 13:48
  3. Replies: 1
    Last Post: 19th October 2010, 05:08
  4. qdbus connect return always FALSE
    By ciberkids in forum Qt Programming
    Replies: 4
    Last Post: 17th September 2009, 14:17
  5. connect() returns true but slot not called
    By OriginalCopy in forum Qt Programming
    Replies: 6
    Last Post: 4th November 2007, 18:54

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
  •  
Qt is a trademark of The Qt Company.