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
Forum Updated to NodeBB v4.3 + New Features

QTableView selection behavior

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 4 Posters 5.7k Views 1 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.
  • A Offline
    A Offline
    Anton Shelenkov
    wrote on 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.!

    JonBJ 1 Reply Last reply
    0
    • A Anton Shelenkov

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

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on 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
      2
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @JonB said in QTableView selection behavior:

        QAbstractItemView::ExtendedSelection

        My money is on that one :)

        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0
          • JonBJ JonB

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

            JonBJ 1 Reply Last reply
            0
            • A Anton Shelenkov

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

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on 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

              • Login

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