Signal to signal

Discuss anything related to product development
Post Reply
baraujo
Posts: 11
Joined: Fri Feb 14 2020 2:47 pm

Signal to signal

Post by baraujo »

Does CopperSpice support signal to signal?

barbara
Posts: 201
Joined: Sat Apr 04 2015 2:32 am

Re: Signal to signal

Post by barbara »

Yes, you can call connect() and have the signal and slot both refer to a signal.

This syntax is not valid:

Code: Select all

connect( sender, SIGNAL(someSignal()), this, SIGNAL(mySignal()) ); 
You can use this syntax:

Code: Select all

connect( sender, SIGNAL(someSignal()), this, SLOT(mySignal()) ); 
However we strongly suggest using method pointers:

Code: Select all

connect( sender, &SenderClass::someSignal, this, &MyClass:: mySignal );

baraujo
Posts: 11
Joined: Fri Feb 14 2020 2:47 pm

Re: Signal to signal

Post by baraujo »

When across threads are they queued automatically like in Qt?

ansel
Posts: 97
Joined: Fri Apr 10 2015 8:23 am

Re: Signal to signal

Post by ansel »

baraujo wrote:
Wed Sep 02 2020 8:29 pm
When across threads are they queued automatically like in Qt?
If I understand your question correctly, you are asking about the behavior when the sender and receiver belong to different threads. We can not confirm that this actually works in Qt, as we observed some undefined behavior in the signal/slot delivery system.

In CopperSpice, if you look at the different overloads for connect() in the QObject class, you will see that the default for the connection type is Qt::AutoConnection. An AutoConnection will automatically queue signals if the sender and receiver are in different threads.

https://www.copperspice.com/docs/cs_api/class_qobject.html

Let us know if you have more questions about connections.
Ansel Sermersheim
CopperSpice Cofounder

Post Reply