How to automatically emit a signal
-
Hello,
I was wondering if there was a way to automatically emit a signal. So instead of, lets say, you clicking a button to calculate something, that instead once you finish editing it, it automatically runs the signal.
Is there a possible way to do this? -
Hello,
I was wondering if there was a way to automatically emit a signal. So instead of, lets say, you clicking a button to calculate something, that instead once you finish editing it, it automatically runs the signal.
Is there a possible way to do this?@rocklionmba said in How to automatically emit a signal:
that instead once you finish editing it, it automatically runs the signal.
What is "it"? Finish editing what? Can you give a specific example of what you're trying to do?
Signals are just regular c++ functions so whatever you can do with regular c++ functions you can do with signals. -
So I have a list of items that all need to be filled out ( Unit of measure, number of coats, material type, quantity, paint type) before any calculations can be done. What I want to do is to have it where once all of them are filled out, it automatically sends the signal to the slots where it calculates it.
-
@rocklionmba said in How to automatically emit a signal:
it automatically sends the signal to the slots where it calculates it
So... still, what is "it"? Who fills these items? A user through some ui or some part of your code?
-
it would be the list of items that's on the ui that the user fills out.
-
It sounds like the goal is to have something happen after several fields are filled out.
eg Send an email after a recipient, subject, and body are entered. These can be done in any order, but a message should only be sent when all three are present.
There's no automatic signal for an arbitrary multi-input use case, but it's easy enough to create one. Create a function that checks each input and emits a signal (or starts the calculation directly) when a valid configuration exists.
void checkValid() { if (input1.isValid && input2.isValid) action(); }Find a change signal for each input, and call the validation function.
Item { id: input1 property bool isValid ... onChanged: checkValid() } Item { id: input 2 property bool isValid ... onChanged: checkValid() } -
-
How do you know " once you finish editing" ?
How will app know user is finished ?