Results 1 to 4 of 4

Thread: QSortFilterProxyModel - crash

  1. #1
    Join Date
    May 2007
    Posts
    301
    Thanks
    46
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QSortFilterProxyModel - crash

    Hi,

    I don't mean this to be a double post, so please forgive me if I should have added this to my last thread.

    I have a model derived from QAbstractTabelModel, this is used with a QTableView. To sort the data in the table, I used the following :

    Qt Code:
    1. m_pModel = new DACanTreeModel();
    2. m_proxyModel = new QSortFilterProxyModel(this);
    3. m_proxyModel->setDynamicSortFilter(true);
    4. m_proxyModel->setSourceModel(m_pModel);
    5.  
    6. list << "ECU" << "Signal" << "Signal Data" << "Real value" << "Unit" << "Count";
    7. m_pModel->setHeaders( list );
    8.  
    9. ui.canTreeView->setSortingEnabled( true );
    10. ui.canTreeView->setModel( m_proxyModel);
    To copy to clipboard, switch view to plain text mode 

    For some reason, data is now not being shown in the table view unless I click on the column headers and when I do, a crash occurs, is the above code wrong? If I set the views model to m_pModel, the data appears, but I cannot sort it.

    Thanks,
    Steve

  2. #2
    Join Date
    May 2007
    Posts
    301
    Thanks
    46
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QSortFilterProxyModel - crash

    Ok, found exactly where the crash is occuring, and it is in my model :

    Qt Code:
    1. int row = theApp->m_dcb[theApp->m_nCanSelected].GetSignalList()->count();
    2. beginInsertRows(QModelIndex(), row, row );
    3. endInsertRows();
    To copy to clipboard, switch view to plain text mode 

    This is only happening since I set my view to use the QSortFilterProxyModel. I guess it must be the QModelIndex() call?

    Regards,
    Steve

  3. #3
    Join Date
    May 2007
    Posts
    301
    Thanks
    46
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QSortFilterProxyModel - crash

    Hi,

    Does anybody know how to get the QModelIndex for the proxy model?

    Regards,
    Steve

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

  5. The following user says thank you to wysota for this useful post:

    steg90 (4th June 2008)

Similar Threads

  1. Crash after updating from Qt4.3 to Qt4.4.0-rc1
    By steg90 in forum Qt Programming
    Replies: 8
    Last Post: 19th May 2008, 17:48
  2. Crash handler on Win32
    By niko in forum Qt Programming
    Replies: 3
    Last Post: 12th November 2007, 19:41
  3. QList crash in destructor
    By mclark in forum Newbie
    Replies: 7
    Last Post: 6th December 2006, 15:27
  4. sendPostedEvents crash
    By stinos in forum Qt Programming
    Replies: 5
    Last Post: 29th October 2006, 09:43
  5. Crash: using a dialog in a model
    By Brandybuck in forum Qt Programming
    Replies: 3
    Last Post: 11th April 2006, 01:39

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.