QAbstractTableModel:::dataChanged() is resetting the QTableView. :|



  • Title says it all. In the interest of testing, I've tried the following slot, mapped to a QPushButton's release() signal.

    Emitting dataChanged() with coordinates 0,0 and 0,0 results in paint() not being called.

    [code]
    my_model_t::handle_change()
    {
    QModelIndex start_ix = createIndex( 0, 0 );
    QModelIndex end_ix = createIndex( 0, 0 );
    emit( dataChanged( start_ix, end_ix ) );
    }
    [/code]

    Slightly changing it to 0,0 through 0,1 means the entire sheet is painted.
    [code]
    my_model_t::handle_change()
    {
    QModelIndex start_ix = createIndex( 0, 0 );
    QModelIndex end_ix = createIndex( 0, 1 );
    emit( dataChanged( start_ix, end_ix ) );
    }
    [/code]

    Worth noting, as there are many rows that are off screen (the QTableView shows about 45 of a few hundred), if I emit coordinates in a range in this off-screen area, paint() is not called.

    [code]
    my_model_t::handle_change()
    {
    QModelIndex start_ix = createIndex( rowCount()-1, columnCount()-1 );
    QModelIndex end_ix = createIndex( rowCount(), columnCount() );
    emit( dataChanged( start_ix, end_ix ) );
    }
    [/code]

    Right now, I'm just marking the sheet as dirty every 100ms or so and letting it repaint the whole screen. With 50 row x 50 columns visible, this gets rather taxing though, and is no more than a band-aid.



  • I dug through the call stack a little, and started catching more slots. I was catching my QTableView's dataChanged() and paintEvent()'s. Basically QTableView::dataChanged() is mangling the coordinates.

    It is apparently behaving as expected. Absolutely shameful documentation if you ask me. There is a huge asterisk missing from QAbstractItemModel::dataChanged() signal and QAbstractItemView::dataChanged() slot.

    Hope nobody else has this problem, and if they do, they can find this thread.

    http://qt-project.org/forums/viewthread/14723


Log in to reply
 

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