Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to handle two different input of two different switch at same time in qt ?
Forum Update on Monday, May 27th 2025

How to handle two different input of two different switch at same time in qt ?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
10 Posts 3 Posters 822 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    Qt embedded developer
    wrote on 23 Mar 2021, 13:34 last edited by
    #1

    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.

    1 Reply Last reply
    0
    • Q Qt embedded developer
      24 Mar 2021, 04:37

      @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 ?

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 24 Mar 2021, 05:23 last edited by
      #4

      @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.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      Q 1 Reply Last reply 25 Mar 2021, 06:44
      1
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 23 Mar 2021, 20:06 last edited by
        #2

        Hi,

        Have one popup that can receive and handle both events.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        Q 1 Reply Last reply 24 Mar 2021, 04:37
        0
        • S SGaist
          23 Mar 2021, 20:06

          Hi,

          Have one popup that can receive and handle both events.

          Q Offline
          Q Offline
          Qt embedded developer
          wrote on 24 Mar 2021, 04:37 last edited by
          #3

          @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 ?

          J 1 Reply Last reply 24 Mar 2021, 05:23
          0
          • Q Qt embedded developer
            24 Mar 2021, 04:37

            @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 ?

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 24 Mar 2021, 05:23 last edited by
            #4

            @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.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            Q 1 Reply Last reply 25 Mar 2021, 06:44
            1
            • J jsulm
              24 Mar 2021, 05:23

              @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.

              Q Offline
              Q Offline
              Qt embedded developer
              wrote on 25 Mar 2021, 06:44 last edited by Qt embedded developer
              #5

              @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

              J 1 Reply Last reply 25 Mar 2021, 06:48
              0
              • Q Qt embedded developer
                25 Mar 2021, 06:44

                @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

                J Offline
                J Offline
                jsulm
                Lifetime Qt Champion
                wrote on 25 Mar 2021, 06:48 last edited by
                #6

                @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...

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                Q 1 Reply Last reply 25 Mar 2021, 06:53
                0
                • J jsulm
                  25 Mar 2021, 06:48

                  @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...

                  Q Offline
                  Q Offline
                  Qt embedded developer
                  wrote on 25 Mar 2021, 06:53 last edited by Qt embedded developer
                  #7

                  @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 .

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 25 Mar 2021, 20:44 last edited by
                    #8

                    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 ?

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    Q 1 Reply Last reply 26 Mar 2021, 04:25
                    0
                    • S SGaist
                      25 Mar 2021, 20:44

                      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 ?

                      Q Offline
                      Q Offline
                      Qt embedded developer
                      wrote on 26 Mar 2021, 04:25 last edited by Qt embedded developer
                      #9

                      @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.
                      }

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on 26 Mar 2021, 20:23 last edited by
                        #10

                        As we already suggested you should implement your own dialog, using the open method so the main loop can continue processing events.

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0

                        1/10

                        23 Mar 2021, 13:34

                        • Login

                        • Login or register to search.
                        1 out of 10
                        • First post
                          1/10
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved