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 selection behavior

QTableView selection behavior

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 4 Posters 5.7k 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.
  • A Offline
    A Offline
    Anton Shelenkov
    wrote on 13 Mar 2019, 17:53 last edited by Anton Shelenkov
    #1

    Hi all, how i can set selection behavior for QTableView like in Windows for files in folder when shift button is pressed?

    I found this:
    view->setSelectionBehavior(QAbstractItemView::SelectRows);

    but it can to change only for whole row/column selection behavior.

    Now:
    0_1552556946148_Untitled1.png

    I need:
    0_1552556953724_Untitled.png

    Thanks.!

    J 1 Reply Last reply 13 Mar 2019, 18:32
    0
    • A Anton Shelenkov
      13 Mar 2019, 17:53

      Hi all, how i can set selection behavior for QTableView like in Windows for files in folder when shift button is pressed?

      I found this:
      view->setSelectionBehavior(QAbstractItemView::SelectRows);

      but it can to change only for whole row/column selection behavior.

      Now:
      0_1552556946148_Untitled1.png

      I need:
      0_1552556953724_Untitled.png

      Thanks.!

      J Offline
      J Offline
      JonB
      wrote on 13 Mar 2019, 18:32 last edited by JonB
      #2

      @Anton-Shelenkov
      I'm afraid I don't get exactly what your example is showing, but look at setSelectionMode(QAbstractItemView::SelectionMode mode), https://doc.qt.io/qt-5/qabstractitemview.html#SelectionMode-enum. QAbstractItemView::ContiguousSelection or QAbstractItemView::ExtendedSelection are what you are looking for?

      A 1 Reply Last reply 14 Mar 2019, 10:00
      2
      • M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 13 Mar 2019, 19:10 last edited by
        #3

        @JonB said in QTableView selection behavior:

        QAbstractItemView::ExtendedSelection

        My money is on that one :)

        1 Reply Last reply
        0
        • C Offline
          C Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 13 Mar 2019, 19:15 last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0
          • J JonB
            13 Mar 2019, 18:32

            @Anton-Shelenkov
            I'm afraid I don't get exactly what your example is showing, but look at setSelectionMode(QAbstractItemView::SelectionMode mode), https://doc.qt.io/qt-5/qabstractitemview.html#SelectionMode-enum. QAbstractItemView::ContiguousSelection or QAbstractItemView::ExtendedSelection are what you are looking for?

            A Offline
            A Offline
            Anton Shelenkov
            wrote on 14 Mar 2019, 10:00 last edited by
            #5

            @Jon I tried that, it's not what i need. I think with pix it will be clearer what i want to.

            J 1 Reply Last reply 14 Mar 2019, 11:03
            0
            • A Anton Shelenkov
              14 Mar 2019, 10:00

              @Jon I tried that, it's not what i need. I think with pix it will be clearer what i want to.

              J Offline
              J Offline
              JonB
              wrote on 14 Mar 2019, 11:03 last edited by JonB
              #6

              @Anton-Shelenkov
              Per your selection picture now shown in your question (much better than your original textual description!)

              I think you certainly do not want setSelectionBehavior(QAbstractItemView::SelectRows), that does what you show and by definition only selects whole rows. I think you must try setSelectionBehavior(QAbstractItemView::SelectItems) to get anything other than whole rows/columns selected. Then combine that with setSelectionMode(), passing QAbstractItemView::ContiguousSelection or (probably) QAbstractItemView::ExtendedSelection, and see how you go?

              1 Reply Last reply
              2

              5/6

              14 Mar 2019, 10:00

              • Login

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