Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. click signal fired when I double click, is this normal?
Qt 6.11 is out! See what's new in the release blog

click signal fired when I double click, is this normal?

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 5 Posters 7.1k Views 3 Watching
  • 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.
  • C Offline
    C Offline
    Chris Bare
    wrote on last edited by
    #1

    I am using Qt 5.10.1 on Linux.
    I have a QTableView with both the clicked and doubleClicked signals connected to slots.
    When I double click, it fires my clicked slot, then my doubleClicked slot, then my clicked slot again.

    Is this normal?
    If so, how can I tell that the first click is part of the double click so I can treat them differently?

    JonBJ 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Yes it's normal, the double click is not a "standalone event", it's two consecutive single clicks.

      Why are you reacting to both ?

      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
      3
      • C Chris Bare

        I am using Qt 5.10.1 on Linux.
        I have a QTableView with both the clicked and doubleClicked signals connected to slots.
        When I double click, it fires my clicked slot, then my doubleClicked slot, then my clicked slot again.

        Is this normal?
        If so, how can I tell that the first click is part of the double click so I can treat them differently?

        JonBJ Online
        JonBJ Online
        JonB
        wrote on last edited by JonB
        #3

        @Chris-Bare

        If so, how can I tell that the first click is part of the double click so I can treat them differently?

        In some shape or form, it it your job to wait to see whether a single click event is followed "shortly" by the double click event. For example, upon single click, start a timer: if the double click arrives cancel the timer and do not process the original as a single click; if it does not arrive by the time of timer expiry, then now process the original event as a single click only.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mpergand
          wrote on last edited by mpergand
          #4

          Well, let's see how it works ...

          void mousePressEvent(QMouseEvent* ev) { qDebug()<<__FUNCTION__;}
          void mouseReleaseEvent(QMouseEvent* ev) {qDebug()<<__FUNCTION__;}
          void mouseDoubleClickEvent(QMouseEvent* ev) {qDebug()<<__FUNCTION__;}
          

          On double click, we have the following sequence:

          mousePressEvent
          mouseReleaseEvent
          mouseDoubleClickEvent
          mouseReleaseEvent
          

          You only need to look at mousePress and doubleClick events.

          For a tableView you can use the following signals:

          connect(tableView,SIGNAL(doubleClicked(const QModelIndex &)), ...
          connect(tableView->selectionModel(),SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), ...
          

          I

          JonBJ 1 Reply Last reply
          0
          • M mpergand

            Well, let's see how it works ...

            void mousePressEvent(QMouseEvent* ev) { qDebug()<<__FUNCTION__;}
            void mouseReleaseEvent(QMouseEvent* ev) {qDebug()<<__FUNCTION__;}
            void mouseDoubleClickEvent(QMouseEvent* ev) {qDebug()<<__FUNCTION__;}
            

            On double click, we have the following sequence:

            mousePressEvent
            mouseReleaseEvent
            mouseDoubleClickEvent
            mouseReleaseEvent
            

            You only need to look at mousePress and doubleClick events.

            For a tableView you can use the following signals:

            connect(tableView,SIGNAL(doubleClicked(const QModelIndex &)), ...
            connect(tableView->selectionModel(),SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), ...
            

            I

            JonBJ Online
            JonBJ Online
            JonB
            wrote on last edited by JonB
            #5

            @mpergand
            Ah, I took @SGaist 's

            Yes it's normal, the double click is not a "standalone event", it's two consecutive single clicks.

            to mean that one received single-click events too when double click. Evidently that is not the case from what you write.

            @Chris-Bare wrote:

            When I double click, it fires my clicked slot, then my doubleClicked slot, then my clicked slot again.

            again that implies to me he gets a clicked event.

            Yet your:

            On double click, we have the following sequence:

            mousePressEvent
            mouseReleaseEvent
            mouseDoubleClickEvent
            mouseReleaseEvent

            shows no single click events at all, so I'm confused/lost?

            J.HilkJ M 2 Replies Last reply
            0
            • JonBJ JonB

              @mpergand
              Ah, I took @SGaist 's

              Yes it's normal, the double click is not a "standalone event", it's two consecutive single clicks.

              to mean that one received single-click events too when double click. Evidently that is not the case from what you write.

              @Chris-Bare wrote:

              When I double click, it fires my clicked slot, then my doubleClicked slot, then my clicked slot again.

              again that implies to me he gets a clicked event.

              Yet your:

              On double click, we have the following sequence:

              mousePressEvent
              mouseReleaseEvent
              mouseDoubleClickEvent
              mouseReleaseEvent

              shows no single click events at all, so I'm confused/lost?

              J.HilkJ Offline
              J.HilkJ Offline
              J.Hilk
              Moderators
              wrote on last edited by
              #6

              @JonB said in click signal fired when I double click, is this normal?:

              Yet your:

              On double click, we have the following sequence:

              mousePressEvent
              mouseReleaseEvent
              mouseDoubleClickEvent
              mouseReleaseEvent

              shows no single click events at all, so I'm confused/lost?

              I don't quite follow the posts as well,

              but clicked() event is usually a combination out of press event and release event

              • mousePressEvent -> pressed()
              • mouseReleaseEvent -> released()
              • mousePressed and Released inside the area of the Widget or one of its children -> clicked()

              so you can have pressed and released events, without triggering clicked.

              but prior to a doubleClicke event, you have 6 Signals: pressed, released, clicked, pressed, released, clicked -> doubleclicked


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              JonBJ 1 Reply Last reply
              1
              • J.HilkJ J.Hilk

                @JonB said in click signal fired when I double click, is this normal?:

                Yet your:

                On double click, we have the following sequence:

                mousePressEvent
                mouseReleaseEvent
                mouseDoubleClickEvent
                mouseReleaseEvent

                shows no single click events at all, so I'm confused/lost?

                I don't quite follow the posts as well,

                but clicked() event is usually a combination out of press event and release event

                • mousePressEvent -> pressed()
                • mouseReleaseEvent -> released()
                • mousePressed and Released inside the area of the Widget or one of its children -> clicked()

                so you can have pressed and released events, without triggering clicked.

                but prior to a doubleClicke event, you have 6 Signals: pressed, released, clicked, pressed, released, clicked -> doubleclicked

                JonBJ Online
                JonBJ Online
                JonB
                wrote on last edited by
                #7

                @J.Hilk said in click signal fired when I double click, is this normal?:

                but prior to a doubleClicke event, you have 6 Signals: pressed, released, clicked, pressed, released, clicked -> doubleclicked

                That is precisely my understanding too, i.e. that you do get 2 clicked events as well as the doubled clicked. And that in turn is why I advised the OP in my post above as to how to go about ignoring the clicked events in this situation.

                However, it is not what @mpergand claims in his "sequence of events for double-click", and I suspect therefore that his analysis is right, in the politest way.

                1 Reply Last reply
                0
                • JonBJ JonB

                  @mpergand
                  Ah, I took @SGaist 's

                  Yes it's normal, the double click is not a "standalone event", it's two consecutive single clicks.

                  to mean that one received single-click events too when double click. Evidently that is not the case from what you write.

                  @Chris-Bare wrote:

                  When I double click, it fires my clicked slot, then my doubleClicked slot, then my clicked slot again.

                  again that implies to me he gets a clicked event.

                  Yet your:

                  On double click, we have the following sequence:

                  mousePressEvent
                  mouseReleaseEvent
                  mouseDoubleClickEvent
                  mouseReleaseEvent

                  shows no single click events at all, so I'm confused/lost?

                  M Offline
                  M Offline
                  mpergand
                  wrote on last edited by mpergand
                  #8

                  Yet your:

                  On double click, we have the following sequence:

                  mousePressEvent
                  mouseReleaseEvent
                  mouseDoubleClickEvent
                  mouseReleaseEvent

                  shows no single click events at all, so I'm confused/lost?

                  A single click means two different events, press and release.
                  The common paradigm used here says: no action takes place on mouse down, only on mouse up.

                  What do you want to do on first click in a row of your tableWiew ?

                  Usely, clicking on a row just means selecting it.
                  On second click, you can allow editing the row.
                  On double clicking, you can open an dialog (for example)
                  This is standard beheaviour you have with signals and slots with a TableView.

                  JonBJ 1 Reply Last reply
                  0
                  • M mpergand

                    Yet your:

                    On double click, we have the following sequence:

                    mousePressEvent
                    mouseReleaseEvent
                    mouseDoubleClickEvent
                    mouseReleaseEvent

                    shows no single click events at all, so I'm confused/lost?

                    A single click means two different events, press and release.
                    The common paradigm used here says: no action takes place on mouse down, only on mouse up.

                    What do you want to do on first click in a row of your tableWiew ?

                    Usely, clicking on a row just means selecting it.
                    On second click, you can allow editing the row.
                    On double clicking, you can open an dialog (for example)
                    This is standard beheaviour you have with signals and slots with a TableView.

                    JonBJ Online
                    JonBJ Online
                    JonB
                    wrote on last edited by
                    #9

                    @mpergand
                    I think your reply may be aimed at the OP, not me.

                    All I was saying, like @J-Hilk , is that your description of the events/signals sent during a double click does not mention the two single click events we, and the OP, believe occur. Period.

                    1 Reply Last reply
                    0

                    • Login

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