How to handle two different input of two different switch at same time in qt ?
-
wrote on 23 Mar 2021, 13:34 last edited by
In my case i have 2 hardware switch. now this both switch get pressed , released and clicked randomly.
on both switch i show different popup. but due to above random click that popup get overlap.
i have tried to handle that trigger but both switch's random triggering impact one another when i pressed , released and clicked both at same time.
how to handle this issue ? i want to know solution of it if any body know let me know.
-
@SGaist here handling event is create problem because when 1st button in pressed state and other button pressed and released before first button then popup overlapping occur. this problem similarly occur for first button also.
though this random trigger happen i want to avoid this situation such that whichever first button get event i want to avoid second button 's all handler.
what logic i need to implement so i can aware which input first triggered ?
@Qt-embedded-developer said in How to handle two different input of two different switch at same time in qt ?:
what logic i need to implement so i can aware which input first triggered ?
Well, if first button is pressed remember that. If then second button is pressed you know that first is already pressed -> ignore.
-
Hi,
Have one popup that can receive and handle both events.
-
wrote on 24 Mar 2021, 04:37 last edited by
@SGaist here handling event is create problem because when 1st button in pressed state and other button pressed and released before first button then popup overlapping occur. this problem similarly occur for first button also.
though this random trigger happen i want to avoid this situation such that whichever first button get event i want to avoid second button 's all handler.
what logic i need to implement so i can aware which input first triggered ?
-
@SGaist here handling event is create problem because when 1st button in pressed state and other button pressed and released before first button then popup overlapping occur. this problem similarly occur for first button also.
though this random trigger happen i want to avoid this situation such that whichever first button get event i want to avoid second button 's all handler.
what logic i need to implement so i can aware which input first triggered ?
@Qt-embedded-developer said in How to handle two different input of two different switch at same time in qt ?:
what logic i need to implement so i can aware which input first triggered ?
Well, if first button is pressed remember that. If then second button is pressed you know that first is already pressed -> ignore.
-
@Qt-embedded-developer said in How to handle two different input of two different switch at same time in qt ?:
what logic i need to implement so i can aware which input first triggered ?
Well, if first button is pressed remember that. If then second button is pressed you know that first is already pressed -> ignore.
wrote on 25 Mar 2021, 06:44 last edited by Qt embedded developer@jsulm there might be situation 1]when pressed button release and other button in pressed state. 2] both button same time pressed 3] same time released
this is situation where it is possible to call 2 slot at a time .
and where i need to put logic when first slot connected i need to not allow other slot to get connected, vice-versa also true for other slot.
so if you know to handle this situation then let me know and provide example code for it
-
@jsulm there might be situation 1]when pressed button release and other button in pressed state. 2] both button same time pressed 3] same time released
this is situation where it is possible to call 2 slot at a time .
and where i need to put logic when first slot connected i need to not allow other slot to get connected, vice-versa also true for other slot.
so if you know to handle this situation then let me know and provide example code for it
@Qt-embedded-developer As I said: as soon as one button gets pressed remember that if then another one is pressed you know that there is already one button pressed. Don't know what else to say here...
-
@Qt-embedded-developer As I said: as soon as one button gets pressed remember that if then another one is pressed you know that there is already one button pressed. Don't know what else to say here...
wrote on 25 Mar 2021, 06:53 last edited by Qt embedded developer@jsulm there might be situation 1]when pressed button release and other button in pressed state. and again released button come in pressed when still other button in pressed state 2] both button same time pressed 3] same time released
this is situation where it is possible to call 2 slot at a time .
-
We understood your use case and the suggestions still holds.
One thing you did not explain is: how does the hardware switch bubble up to your application ?
-
We understood your use case and the suggestions still holds.
One thing you did not explain is: how does the hardware switch bubble up to your application ?
wrote on 26 Mar 2021, 04:25 last edited by Qt embedded developer@SGaist i have used 2 Qfilesystemwatcher . we have selected both edge change for switch.
On release and pressed state of switch pin value change to 1 and 0 . at that time filechanged signal got emitted and it call the slot.
this way i used hardware switch bubbled up in my application.
my logic for hardware switch 1's slot :
if ( Water flow == false)
{if(file changed value == 1)
{
start water flow (); // this function show implemented widget which wait for user click on Qpushbutton. until user not click on it this popup will stay there
}
else
stop water flow();
}my logic for hardware switch switch 2's slot :
if(water flow == false)
{
show message box(); // this show just Qmessagebox with simple ok button. now this message box also stay there until user click on ok button. this not start or stop water flow. this just show user that water flow not started. it not start or not stop water flow but it don't get close until user click on ok button.
} -
As we already suggested you should implement your own dialog, using the open method so the main loop can continue processing events.
1/10