Results 1 to 6 of 6

Thread: What happens if QSortFilterProxyModel has no sourceModel?

  1. #1
    Join Date
    Oct 2008
    Location
    Beijing China
    Posts
    77
    Thanks
    21
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default What happens if QSortFilterProxyModel has no sourceModel?

    Since QSortFilterProxyModel can be set data, what will happen if
    Qt Code:
    1. for( qint32 i = 0; i < 5; i++)
    2. {
    3. for( qint32 j = 0; j < 5; j++)
    4. {
    5. QModelIndex index(i, j);
    6. proxyModel->setData(QVariant(), index);
    7. }
    8. }
    9. QTableView *tableView = new QTableView(this);
    10. tableView->setModel(proxyModel);
    11. tableView->setSortingEnabled(true);
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: What happens if QSortFilterProxyModel has no sourceModel?

    I guess nothing will appear on view...
    If you have tried it, you can tell us the answer :P

  3. #3
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: What happens if QSortFilterProxyModel has no sourceModel?

    of course it wont show anything, first of all, your index would always be invalid like this, secondly, even if setData is called, it would be called of QAbstractItemModel!!
    no use of this whole code..

  4. #4
    Join Date
    Oct 2008
    Location
    Beijing China
    Posts
    77
    Thanks
    21
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Wink Re: What happens if QSortFilterProxyModel has no sourceModel?

    Quote Originally Posted by aamer4yu View Post
    I guess nothing will appear on view...
    If you have tried it, you can tell us the answer :P
    u'r right , nothing shows.

  5. #5
    Join Date
    Oct 2008
    Location
    Beijing China
    Posts
    77
    Thanks
    21
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: What happens if QSortFilterProxyModel has no sourceModel?

    Quote Originally Posted by talk2amulya View Post
    of course it wont show anything, first of all, your index would always be invalid like this, secondly, even if setData is called, it would be called of QAbstractItemModel!!
    no use of this whole code..
    yes. then i tried to insert rows and columns to the proxy model and called setData(), some items appears and some does not, and there're repeat ones, i think that is because i set the proxy model sort dynamically, and set data to exiting items. anyway, source model is easier to handle, especially use a QStandardItemModel.

  6. #6
    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

    Default Re: What happens if QSortFilterProxyModel has no sourceModel?

    I think that's because you are using the proxy in a way it was not meant to be used. Attach a source model to it.
    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.


Similar Threads

  1. How to map the rows to sourceModel rows.
    By kaushal_gaurav in forum Qt Programming
    Replies: 2
    Last Post: 11th February 2009, 08:40
  2. Using QSortFilterProxyModel
    By Jennie Bystrom in forum Qt Programming
    Replies: 3
    Last Post: 6th December 2007, 10:28

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.