Results 1 to 2 of 2

Thread: QStandardItemModel and match function - exception in Qt code

  1. #1
    Join Date
    Nov 2009
    Posts
    44
    Thanks
    8
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QStandardItemModel and match function - exception in Qt code

    I have a QStandardItemModel that I am using in a QTreeView. It has several levels, and I want to allow the user to expand/contract a specific level. Some of the levels are siblings, I want to allow the user to expand one sibling, but not another. I store the 'name' of the level in Qt::UserRole+1. When the QTreeView displays, a QComboBox with the names gets populated, along with defaults of Expand All and Expand None. I have a signal/slot triggered by changing the Expand Level in the combo box. Expand All and Expand None work fine. I am using the code below:
    Qt Code:
    1. void RWPreview::changeExpand( QString level )
    2. {
    3. QModelIndexList idx_list;
    4. if( level.compare( "All") == 0 )
    5. rpt_view-> expandAll();
    6.  
    7. else if( level.compare("None") == 0 )
    8. rpt_view-> collapseAll();
    9.  
    10. else
    11. {
    12. QModelIndex st_idx = ((QStandardItemModel*)rpt_view->model() )->index(0,0);
    13. idx_list = rpt_view->model()->match(st_idx, Qt::UserRole+1, qVariantFromValue(level), -1, Qt::MatchRecursive );
    14. QListIterator<QModelIndex> i( idx_list );
    15. while (i.hasNext())
    16. rpt_view->expand( i.next() );
    17.  
    18. }
    19.  
    20. }
    To copy to clipboard, switch view to plain text mode 
    I get the expected number of model indexes for the expected rows in the QModelIndexList. It completes the while loop, and exits the if statement. However, when it exits the function, I get an exception. Does anyone have an idea what I can try? If I dont' create the QModelIndexList, it works fine (but obviously, doesn't expand nodes). I'm puzzled!

  2. #2
    Join Date
    Nov 2009
    Posts
    44
    Thanks
    8
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QStandardItemModel and match function - exception in Qt code

    I stumbled across the "answer" to this issue. According to http://www.qtcentre.org/threads/27769 , this is caused by linking to release libraries rather than debug libraries when in debug mode. You can see more information at http://bugreports.qt.nokia.com/browse/QTBUG-7884.

    However, in my project, I'm explicitly linking to debug libraries for the debug build (and release libraries for the release build). I'm using 4.6.2. Can anyone give me hints of what to look for????

Similar Threads

  1. no match for 'operator=' in...
    By toss in forum Newbie
    Replies: 2
    Last Post: 14th April 2010, 00:08
  2. Replies: 1
    Last Post: 21st September 2009, 07:30
  3. Public function called on MDISubWindow ignores code
    By ad5xj in forum Qt Programming
    Replies: 2
    Last Post: 24th February 2009, 16:29
  4. Match the text beetween two string
    By dreamer in forum Qt Programming
    Replies: 4
    Last Post: 20th May 2008, 14:48
  5. No match for operator>>
    By Salazaar in forum Newbie
    Replies: 18
    Last Post: 12th June 2007, 17:48

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.