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. How to change selection in QTableWidget on keypress
Forum Updated to NodeBB v4.3 + New Features

How to change selection in QTableWidget on keypress

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 3.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.
  • G Offline
    G Offline
    GregPhil
    wrote on last edited by GregPhil
    #1

    I'm looking for a documentation that would explain how the QTableWidget reacts on keystrokes.
    I have a 5x5 Table where I set the selection behaviour to QAbstractItemView::SelectRows. However, as soon I have one row selected, I can change the row by pressing keys on the keyboard. In my case for selection it is the first character in the cells of the second column, which is taking into account.
    How I can get the first or the third column getting crucial for the selection.
    Would someone please be so kind and point me to the place in doc, there I can find some notes how this implementation works and how to change it?

    Thank you in advance.
    Greg

    JonBJ 2 Replies Last reply
    0
    • G GregPhil

      I'm looking for a documentation that would explain how the QTableWidget reacts on keystrokes.
      I have a 5x5 Table where I set the selection behaviour to QAbstractItemView::SelectRows. However, as soon I have one row selected, I can change the row by pressing keys on the keyboard. In my case for selection it is the first character in the cells of the second column, which is taking into account.
      How I can get the first or the third column getting crucial for the selection.
      Would someone please be so kind and point me to the place in doc, there I can find some notes how this implementation works and how to change it?

      Thank you in advance.
      Greg

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

      @GregPhil
      Have you read QItemSelectionModel http://doc.qt.io/qt-5/qitemselectionmodel.html#details ?

      current selected items are part of the current interactive selection (for example with rubber-band selection or keyboard-shift selections).

      And http://doc.qt.io/qt-5/model-view-programming.html#handling-selections-in-item-views.

      1 Reply Last reply
      1
      • G GregPhil

        I'm looking for a documentation that would explain how the QTableWidget reacts on keystrokes.
        I have a 5x5 Table where I set the selection behaviour to QAbstractItemView::SelectRows. However, as soon I have one row selected, I can change the row by pressing keys on the keyboard. In my case for selection it is the first character in the cells of the second column, which is taking into account.
        How I can get the first or the third column getting crucial for the selection.
        Would someone please be so kind and point me to the place in doc, there I can find some notes how this implementation works and how to change it?

        Thank you in advance.
        Greg

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

        @GregPhil said in How to change selection in QTableView on keypress:

        I'm looking for a documentation that would explain how the QTableWindow reacts on keystrokes.

        BTW: QTableWindow is QTableView, or QTableWidget, or ...?

        G 1 Reply Last reply
        0
        • JonBJ JonB

          @GregPhil said in How to change selection in QTableView on keypress:

          I'm looking for a documentation that would explain how the QTableWindow reacts on keystrokes.

          BTW: QTableWindow is QTableView, or QTableWidget, or ...?

          G Offline
          G Offline
          GregPhil
          wrote on last edited by
          #4

          @JNBarchan
          oh yes I'm sorry, I mixed up the terms. It's always QTableWidget.
          I think your ansers apply to QTableView but not to QTableWidget?

          JonBJ 1 Reply Last reply
          0
          • G GregPhil

            @JNBarchan
            oh yes I'm sorry, I mixed up the terms. It's always QTableWidget.
            I think your ansers apply to QTableView but not to QTableWidget?

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

            @GregPhil
            QTableWidget inherits from QTableView so stuff still applies.

            I am a newcomer, but unless I am mistaken they do not offer any kind of inbuilt:

            can change the row by pressing keys on the keyboard. In my case for selection it is the first character in the cells of the second column

            , just mouse selection support. So that implies it is your code which has the logic for whatever it is doing for "selection by second column", and that is where you would put code to change this behaviour to whatever you desire?

            G 1 Reply Last reply
            0
            • JonBJ JonB

              @GregPhil
              QTableWidget inherits from QTableView so stuff still applies.

              I am a newcomer, but unless I am mistaken they do not offer any kind of inbuilt:

              can change the row by pressing keys on the keyboard. In my case for selection it is the first character in the cells of the second column

              , just mouse selection support. So that implies it is your code which has the logic for whatever it is doing for "selection by second column", and that is where you would put code to change this behaviour to whatever you desire?

              G Offline
              G Offline
              GregPhil
              wrote on last edited by
              #6

              @JNBarchan
              ok thank you very much.
              Strange, even if I got the same impression that only mouse selection support is provided by reading the documentation, keystrokes working as well. One can easy verify this. It's only the fact that I can't find any documentation how to adjust this behaviour it to my needs. However, the only idea I have for now (without having a look into it) seems to be an addaption by implementing/overwriting events.

              cheers

              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