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. Tab order of QTableWidget after editing a cell
Qt 6.11 is out! See what's new in the release blog

Tab order of QTableWidget after editing a cell

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 1.1k 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.
  • J Offline
    J Offline
    johnsmith12
    wrote on last edited by johnsmith12
    #1

    I've got a QTableWidget with 4 columns and many rows in which only several are visible (and the rest can be viewed scrolling down). Each cell is set with setCellWidget() with a QDoubleSpinBox.

    The tab order works as expected initially (In order of cell creation, default order). When I enter or edit a cell anywhere in the list of cells though, the tab order picks up from the last tabbed cell rather than from the cell in which I entered/edited. I would like the tab order to be reset to wherever currently entered.

    • I can accomplish this when setting QTableWidget's setTabKeyNavigation() to false. The issue here is once I tab into a cell out visible range the scrollbar doesn't automatically scroll down.

    • I tried using QLineEdit instead of QDoubleSpinBox but it doesn't matter, same result.

    • I've tried setting the setTabOrder() for each QDoubleSpinBox but does not work.

    • Signals cellPressed(), cellClicked(), itemPressed(), itemClicked() don't work but currentCellChanged() does.

    Any suggestions on approach to resolve here?

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

      Hi,

      Why are you using setCellWidget and not a QDoubleSpinBox based QStyledItemDelegate ?

      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
      1
      • J Offline
        J Offline
        johnsmith12
        wrote on last edited by johnsmith12
        #3

        Because I wanted to make all cells editable at once rather than having createEditor() in the delegate called only when double clicking a cell and the remaining cells be read-only.

        Is it possible to do this with QStyledItemDelegate? I have the basic example (from http://doc.qt.io/archives/qt-4.8/qt-itemviews-spinboxdelegate-example.html) working but I need all spinboxes to be editable at once.

        1 Reply Last reply
        0
        • J Offline
          J Offline
          johnsmith12
          wrote on last edited by johnsmith12
          #4

          Alternatively, I could replace the double click with just a single click cell selection to show spinbox ... this would suffice as tabbing would then create the next spinbox.

          https://stackoverflow.com/questions/18831242/qt-start-editing-of-cell-after-one-click suggests doing this on mousepressevent. Would this be your suggestion as well?

          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