Solved Help with logic
-
@mrjj , thats why I am connecting the original signal to a slot which has the specific arguments and acts as a repeater because it builds a common object and then emits a signal which is connected to the lambda slot.
-
@JKSH , I tried that before posting, it didn't help because the auto keyword has to be used when assigning, I cannot defined an auto outside of a conditional block, assign the auto variables then use them after the conditional block.
-
@SPlatten said in Help with logic:
@mrjj , thats why I am connecting the original signal to a slot which has the specific arguments and acts as a repeater because it builds a common object and then emits a signal which is connected to the lambda slot.
So the repeater lambda wont have any parameters ?
-
Actually, I think I was thinking about it all wrong, there isn't actually a problem, since the original signals are connected to a slot that matches up with the signal in terms of parameters then all or those slots emit a common signal with the same parameters.
Sorry, I was not giving it enough thought.
-
@SPlatten
Ah ok then it makes more sense.
So normal signal to slot and then it also sends the signal to same lambda not using any parameters ? -
@mrjj the repeater slot isn't Lambda, the connection is as follows, using QPushButton clicked as an example:
clicked -> rptrClicked
The clicked signal originates directly from the QPushButton widget, the rptrClicked slot is defined in my derived QPushButton widget.
rptClicked, constructs a JSON object and emits a common signal which is used by all repeater slots with a member array variable containing the original slot specific parameters.
Then all I do is connect the common signal to anything that is interested in it.
-
@SPlatten `
aha, i think i get it.
So what you currently struggling with is saving the original connect paramters?
And since you want a lambda, we cant just use SIGNAL and SLOT macros and store as char * ? -
@mrjj , its taken a while but now I think I've got a solution which is easy to replicate and will provide me with a mechanism which is reusable for any and all signals.
-
@SPlatten
Ok cool :) -
@JKSH , @mrjj , thanks for your help, I now have a working solution that I think is a big step forward.
What I'm doing is:
- Create a class based on a Qt control, e.g. QPushButton
- In my derived class I connect all signals to internal repeater slots. Each repeater then creates a JSON object with the parameter differences that exist in each signal, the JSON also contains a timestamp of when the signal was received and the name of the signal.
- The repeater slot then emits a common signal with the JSON object as the sole parameter.
- The common signal is connected in the application is connected to all subscribers interested in the original control signals.
This works great and now all I need to do is replicate this process for all the controls.
Here is a sample of the Application Output from my rather verbose debug information:
S00000000000000000087 Debug:simon2.js L00000049:-----clicked()-----
S00000000000000000088 Debug:simon2.js L00000022:id(string): btn1
S00000000000000000089 Debug:simon2.js L00000022:checked(boolean): true
S00000000000000000090 Debug:simon2.js L00000022:sid(string): win1
S00000000000000000091 Debug:simon2.js L00000022:signal(string): clicked
S00000000000000000092 Debug:simon2.js L00000022:timestamp(string): 1595322480381The S number at the start of the line is the sequence number, always incrementing, then the type of message, the name of the script file, line number in the script file, then finally the message content itself, which in this case is just a dump of the JSON object received.