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. QAbstractTableModel:::dataChanged() is resetting the QTableView. :|
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 5.4k 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.
  • G Offline
    G Offline
    gaijinpunch
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      gaijinpunch
      wrote on last edited by
      #2

      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

      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