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. QTableView clicked() not triggering when dragging and selecting a range of data in the table?
QtWS25 Last Chance

QTableView clicked() not triggering when dragging and selecting a range of data in the table?

Scheduled Pinned Locked Moved Solved General and Desktop
qtableviewtableviewtabletable view
7 Posts 3 Posters 1.6k 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.
  • R Offline
    R Offline
    R-P-H
    wrote on last edited by R-P-H
    #1

    Hi,

    I have a slot for QTableView clicked(QModelIndex index). I noticed that if I click and drag a selection in the table (extended selection) the clicked() signal is not emitted? Clicking a single record works fine though.

    jsulmJ JonBJ 2 Replies Last reply
    0
    • R R-P-H

      Hi,

      I have a slot for QTableView clicked(QModelIndex index). I noticed that if I click and drag a selection in the table (extended selection) the clicked() signal is not emitted? Clicking a single record works fine though.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @R-P-H Mouse click means that mouse button was pressed AND released over same widget. Pressing mouse button down over one widget and releasing it over another isn't a click.
      You can use https://doc.qt.io/qt-6/qabstractitemview.html#pressed

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

      R 1 Reply Last reply
      2
      • R R-P-H

        Hi,

        I have a slot for QTableView clicked(QModelIndex index). I noticed that if I click and drag a selection in the table (extended selection) the clicked() signal is not emitted? Clicking a single record works fine though.

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

        @R-P-H
        clicked() is for a single cell. selectionChanged() will happen for your drag, or QItemSelectionModel::selectionChanged() on the selectionModel().

        R 1 Reply Last reply
        0
        • JonBJ JonB

          @R-P-H
          clicked() is for a single cell. selectionChanged() will happen for your drag, or QItemSelectionModel::selectionChanged() on the selectionModel().

          R Offline
          R Offline
          R-P-H
          wrote on last edited by
          #4

          @JonB Any slot that can capture both the click and drag ?

          JonBJ 1 Reply Last reply
          0
          • R R-P-H

            @JonB Any slot that can capture both the click and drag ?

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

            @R-P-H
            No, because as @jsulm wrote you are not clicking. A click is a mouse down and up while on a cell. But you don't do that, do you? You mouse down and then drag-move the mouse while still down without up, don't you? Which is why he gave you a reference to pressed() signal instead. And you can't have one signal for "both the click and drag" even if "click" is "press" because they happen at different times. Or, doubtless you can re-implement drag-selection yourself and do what you want there, but can't believe it's worth the effort or a good idea.

            R 1 Reply Last reply
            1
            • JonBJ JonB

              @R-P-H
              No, because as @jsulm wrote you are not clicking. A click is a mouse down and up while on a cell. But you don't do that, do you? You mouse down and then drag-move the mouse while still down without up, don't you? Which is why he gave you a reference to pressed() signal instead. And you can't have one signal for "both the click and drag" even if "click" is "press" because they happen at different times. Or, doubtless you can re-implement drag-selection yourself and do what you want there, but can't believe it's worth the effort or a good idea.

              R Offline
              R Offline
              R-P-H
              wrote on last edited by
              #6

              @JonB Thanks, I understand.

              1 Reply Last reply
              0
              • jsulmJ jsulm

                @R-P-H Mouse click means that mouse button was pressed AND released over same widget. Pressing mouse button down over one widget and releasing it over another isn't a click.
                You can use https://doc.qt.io/qt-6/qabstractitemview.html#pressed

                R Offline
                R Offline
                R-P-H
                wrote on last edited by
                #7

                @jsulm said in QTableView clicked() not triggering when dragging and selecting a range of data in the table?:

                @R-P-H Mouse click means that mouse button was pressed AND released over same widget. Pressing mouse button down over one widget and releasing it over another isn't a click.
                You can use https://doc.qt.io/qt-6/qabstractitemview.html#pressed

                pressed() worked for me. Thanks !

                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