Results 1 to 6 of 6

Thread: SortFilterProxyModel data

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2007
    Posts
    99
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: SortFilterProxyModel data

    if anyone was interested...heres my code storing those data...yes it could be written better way...but it solves the problem

    Qt Code:
    1. QTextStream out(&file);
    2. for(int row=0; row<filterModel->rowCount();row++){
    3. QModelIndex index0 = filterModel->index(row, 0);
    4. QModelIndex sourceIndex0 = filterModel->mapToSource(index0);
    5. out << sourceIndex0.data().toInt()<<"\t";
    6. QModelIndex index1 = filterModel->index(row, 1);
    7. QModelIndex sourceIndex1 = filterModel->mapToSource(index1);
    8. out << sourceIndex1.data().toInt()<<"\t";
    9. QModelIndex index2 = filterModel->index(row, 2);
    10. QModelIndex sourceIndex2 = filterModel->mapToSource(index2);
    11. out << sourceIndex2.data().toString()<<"\t"<<endl;
    12. }
    To copy to clipboard, switch view to plain text mode 

    although it assumes that model has 3 columns...
    Last edited by gyre; 5th December 2007 at 20:50. Reason: updated contents

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: SortFilterProxyModel data

    This should be enough:
    Qt Code:
    1. QTextStream out( &file );
    2. for( int row=0; row < filterModel->rowCount(); ++row ) {
    3. QModelIndex index0 = filterModel->index( row, 0 );
    4. QModelIndex index1 = filterModel->index( row, 1 );
    5. QModelIndex index2 = filterModel->index( row, 2 );
    6. out << index0.data().toInt() << "\t";
    7. out << index1.data().toInt() << "\t";
    8. out << index2.data().toString() << endl;
    9. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Sep 2007
    Posts
    99
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: SortFilterProxyModel data

    Quote Originally Posted by jacek View Post
    This should be enough:
    Qt Code:
    1. QTextStream out( &file );
    2. for( int row=0; row < filterModel->rowCount(); ++row ) {
    3. QModelIndex index0 = filterModel->index( row, 0 );
    4. QModelIndex index1 = filterModel->index( row, 1 );
    5. QModelIndex index2 = filterModel->index( row, 2 );
    6. out << index0.data().toInt() << "\t";
    7. out << index1.data().toInt() << "\t";
    8. out << index2.data().toString() << endl;
    9. }
    To copy to clipboard, switch view to plain text mode 
    nice...thats definitely programmatically better man...thanks

Similar Threads

  1. Replies: 4
    Last Post: 19th October 2007, 19:47
  2. Data model
    By steg90 in forum Qt Programming
    Replies: 3
    Last Post: 17th September 2007, 12:14
  3. speed of setdata - lots of items in treeview
    By Big Duck in forum Qt Programming
    Replies: 4
    Last Post: 6th July 2006, 12:53
  4. How to convert binary data to hexadecimal data
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 8th March 2006, 16:17
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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
  •  
Qt is a trademark of The Qt Company.