Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-138513

QTableView setSpan + moveSection causes selection mismatch

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P4: Low
    • None
    • 6.8.2
    • Widgets: Itemviews
    • None
    • Windows

    Description

      There were no errors in this situation in Qt version 5.11.2

      When using a QTableView with a model, if cells are spanned vertically using setSpan and then columns are reordered using moveSection on the horizontal header, mouse clicks and selections on cells to the right of the moved column are incorrectly mapped to the column on the left of the moved position.
       
      Steps to Reproduce:

      • Create a QTableView with a model containing 5 rows and 6 columns.
      • Apply vertical cell spans:
         
        ui->tableView->setSpan(0, 0, 2, 1); // Span 2 rows in column 0, starting at row 0
        ui->tableView->setSpan(3, 0, 2, 1); // Span 2 rows in column 0, starting at row 3 
      • Move column 4 to position 2:
        ui->tableView->horizontalHeader()->moveSection(4, 2);

         

      • Click inside the table body (not on the header) on the third column (index 2) or further to the right.

       
      Expected Behavior:

      Mouse clicks and selections should correctly target and highlight the cell that was clicked, regardless of previous setSpan and moveSection operations.
       
      Actual Behavior:

      • Clicking on the third column (index 2) or any column to the right of it causes selection of the cell in the previous column (index 1 or lower than expected).
      • Clicking on the second column (index 1) or to the left works correctly.

      Notes:

      • The visual layout appears correct: column 4 has been moved between columns 2 and 3.
      • This issue occurs only in the table body area, not in the header.
      • This suggests a mismatch in how the view maps logical columns to visual positions after both setSpan and moveSection are used.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            jakepauldev Jake Paul
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes