Results 1 to 4 of 4

Thread: Easy yes/no QSortFilterProxyModel question...

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2011
    Location
    Richmond, VA
    Posts
    94
    Thanks
    14
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Easy yes/no QSortFilterProxyModel question...

    For you QSortFilterProxyModel experts out there -- if I've created a proxy model between a QSqlTableModel and my view, would I add new rows to the proxy model or the underlying table model? I'm in the process of converting my code to the proxy, so I'm still adding data to the table model, and it works, but I wasn't sure if that's by accident...

    Thanks!


    scott

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

    Default Re: Easy yes/no QSortFilterProxyModel question...

    It doesn't matter, both should work. Provided that the proxy dynamically adjusts to the underlying model.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jan 2011
    Location
    Richmond, VA
    Posts
    94
    Thanks
    14
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Easy yes/no QSortFilterProxyModel question...

    Good to know...I was getting some index errors earlier in another function I was using but the data was being saved to the DB okay...

    After I add a row to a SQL model I check the index on the model and it was pointing to the newly added row, but after I'd set the current index on my tableview to this row, the tableview still showed it's index to be wherever I might have previously clicked on the tableview before adding my new row...I wasn't expecting that...I'd like it to be pointing to my new row but I'll work on that...

    thanks!

    scott

  4. #4
    Join Date
    Jan 2011
    Location
    Richmond, VA
    Posts
    94
    Thanks
    14
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Easy yes/no QSortFilterProxyModel question...

    Figured it out -- after adding a row to my underlying model, I attempted to set the current index on my tableview to the index of the model, but *instead* I needed to set it to the index of the proxy model.

    This is what I had been doing
    Qt Code:
    1. flowpathmodel->insertRow(row);
    2. fp_index = flowpathmodel->index (row, 0);
    3. ui->FlowpathTV->setCurrentIndex (fp_index);
    To copy to clipboard, switch view to plain text mode 

    When I should be doing this
    Qt Code:
    1. flowpathmodel->insertRow(row);
    2. proxyindex = flowpathproxy->index (row, 0);
    3. ui->FlowpathTV->setCurrentIndex (proxyindex);
    To copy to clipboard, switch view to plain text mode 

    When I'd inserted a new row I had expected the selection to remain with my new row, and it did with the model but not the proxy model, and now you can see why...I need to not mix and match using the underlying model with the proxy model -- one or the other, but that's the next step


    scott

Similar Threads

  1. easy mathematics
    By uygar in forum Qt Programming
    Replies: 3
    Last Post: 6th October 2010, 20:07
  2. Easy Signal-Slot-Problem
    By nearlyNERD in forum Qt Programming
    Replies: 2
    Last Post: 6th March 2010, 22:33
  3. QTextEdit... was ->text() too easy?
    By Raccoon29 in forum Newbie
    Replies: 2
    Last Post: 16th March 2008, 16:58
  4. Replies: 2
    Last Post: 14th February 2008, 20:06
  5. yet another easy task i cant figure out
    By sincnarf in forum Qt Programming
    Replies: 5
    Last Post: 16th October 2007, 05:46

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.