Qt World Summit: Register Today!

Strange behavior on Column pinning QTableWidget

  • I have written a QTableWidget whose first two columns are pinned i.e. always remains in view even if horizontally scrolled based on https://doc.qt.io/qt-5/qtwidgets-itemviews-frozencolumn-example.html

    My selection mode is per row, one row at a time. When I click on any row within the pinned columns, the selection works correctly, however, when I click on any row and the column is outside the pinned ones (to the right), a strange behavior is displayed i.e. the 1st pinned column (column #0) gets hidden and the first non-pinned column (column #2) gets displayed twice, adjacent to each other.

    What could be the possible culprit? I have planted breakpoints in all the methods I override, it doesn't hit anything at all. Does it have anything to do with the two QTableViews sharing the same selection model? Should it be separate?

  • Lifetime Qt Champion

    @ajaxcrypto said in Strange behavior on Column pinning QTableWidget:

    What could be the possible culprit?

    Please provide a minimal, compilable example - otherwise we can just do wild guesses.

  • I finally figured it out with lots of trial and error. The culprit was sharing of item selection model across the two views. Had to keep them independent and synchronize on signals instead.

Log in to reply