[SOLVED] Problem clicking on QTableView

  • Hi,

    I have a problem with a table derived from QTableView. The table has 11 rows, but only 10 are
    visible, so I need to scroll down to see the last row. When I scroll down to the bottom and click
    on a cell in row 11, the cell is selected without problems, but then, if I click on the cell next
    to it (at right or left), that cell is not selected; instead of that, the cell in the same column,
    but in the row 10, is selected. I've tried reading the number of the row and column with rowAt()
    and columnAt(), using the function mousePressEvent(), and data I get agree with the observed

    I don't know if it's a bug or it's my fault.

    Any help will be appreciate. Thanks.

  • Looks like it's your fault. I do not have those problems in my own QTableView subclasses, nor did I hear of any such.

    The best approach is to boil down the problem to a very simple and small test case, just a main method, your table view subclass (stripped down to the essential changes) and a widget that integrates all. Chances are good that you even find the cause of the problem while preparing the test :-)

  • [SOLVED]

    The problem was with the sentence setEditStrategy(QSqlTableModel::OnFieldChange), in the constructor of the class derived from QSqlTableModel. That sentence made QTableView to repopulate and scroll to top after editing a cell. To circumvent the problem I need to replace the previous sentence with setEditStrategy(QSqlTableModel::OnManualSubmit), and call submitAll() when I finish editing the table.

    I was going mad :-)

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.