Results 1 to 1 of 1

Thread: QTableView and QItemSelection model bug.

  1. #1
    Join Date
    Dec 2006
    Posts
    160
    Thanks
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTableView and QItemSelection model bug.

    Hello everybody,

    i'm facing a rather odd bug using a QTableView linked to a custom derived QSqlTableModel.
    Basically, my table view displays data from a SQLite backend, itself being accessed via a very simple QSqlTableView derived model.
    However, random behavior happens. For instance, if i press Ctrl+A to select everything in the table, only the first 256 rows gets selected.
    Then if i play with the GUI and scroll up / down, i'm then able to manually select the remaining rows (39 of them, i have 295 records in my table).
    The other very annoying bug is that if i select any row after the 256th, i can't change it's value. For instance, i have buttons to allow checking / unchecking several rows at the same time. This button works only on the first 256th rows displayed by the table:
    Qt Code:
    1. void REA::WgtDocumentTypesManager::on_btnSampleImagesCheck_clicked () {
    2. while (_siModel->canFetchMore()) _siModel->fetchMore();
    3. QModelIndexList rows = ui.tblVwSampleImages->selectionModel()->selectedRows();
    4. foreach (QModelIndex const &i, rows)
    5. _siModel->setData (_siModel->index(i.row(), SampleImagesModel::Training), 1);
    6. }
    To copy to clipboard, switch view to plain text mode 
    What can i possibly be doing wrong here?

    i tried putting some [ while (canFetchMore()) fetchMore(); ] ish code all over, nothing changes.

    Thanks a lot,
    Pierre.


    Added after 32 minutes:


    i temporarilly solved my problem by doing this in my QSqlTableModel derived model:
    Qt Code:
    1. bool REA::SampleImagesModel::select () {
    2. bool toRet = QSqlTableModel::select();
    3. while (canFetchMore()) fetchMore();
    4. return toRet;
    5. }
    To copy to clipboard, switch view to plain text mode 
    Which means that there is probably a bug in the implementation of QTableView.

    Any idea on how to properly solve this please?
    Last edited by hickscorp; 17th November 2011 at 17:49.

Similar Threads

  1. Event handlers for QTableView model / selection model.
    By hickscorp in forum Qt Programming
    Replies: 2
    Last Post: 8th July 2011, 17:57
  2. Replies: 1
    Last Post: 24th February 2011, 05:54
  3. QItemSelection, does not copy all area
    By Mnemonic in forum Qt Programming
    Replies: 0
    Last Post: 26th March 2010, 09:41
  4. Invalid QItemSelection from QItemSelectionModel
    By TheRonin in forum Qt Programming
    Replies: 1
    Last Post: 9th February 2010, 16:31
  5. QTableView Model Help
    By tntcoda in forum Qt Programming
    Replies: 3
    Last Post: 23rd June 2008, 06:57

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.