Results 1 to 6 of 6

Thread: QSortFilterProxyModel and accissing data

  1. #1
    Join Date
    Apr 2013
    Posts
    4
    Qt products

    Default QSortFilterProxyModel and accissing data

    First I program in PyQt but can read code in Qt

    I have a proxymodel derived QSortFilterProxyModel

    I this class I reimplement filterAccepsRow()
    Here I can access my data with model=sourceModel()

    My question:

    How can I access my data outside this filterAccepsRows() because in the class body sourceModel() is not working

    Any hints are welcome.
    Thanks in advance.

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QSortFilterProxyModel and accissing data

    How can I access my data outside this filterAccepsRows() because in the class body sourceModel() is not working
    Why do you need to access the filter data outside the class?

    sourceModel() will return a model only when a source model is on the proxy model
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Apr 2013
    Posts
    4
    Qt products

    Default Re: QSortFilterProxyModel and accissing data

    Not outside the class.

    Inside the class but not in filterAccepsRow()

    I have the following pseudo code

    class sortfilterproxymodel

    def populate_combobox():
    access data needed to populate combobox
    model=sourceModel() <-- this is not working

    def filteracceptsrow()
    model=sourceModel() <-- this is working
    do stuff <-- OK

    I assume I'm doing something wrong so a hint will be appreciated.

  4. #4
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QSortFilterProxyModel and accissing data

    model=sourceModel() <-- this is not working
    What dou mean not working? are you sure the source model is set before that?
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  5. #5
    Join Date
    Apr 2013
    Posts
    4
    Qt products

    Default Re: QSortFilterProxyModel and accissing data

    I'm sure because everything is working, my delegate, my tableview, my model even filtering is working as I expect.

    The only exception is that I cannot populate the combobox with the data because I cannot access the data in the main body of sortfilterproxymodel class.

  6. #6
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QSortFilterProxyModel and accissing data

    Do you want to access filterted data, or the un-filtered data?

    In most cases sourceModel is not required to be used, unless custom filterring is being employed?

    I think it's time to see what you are doing to populate the combo box? Show us the code to populate the combo box.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

Similar Threads

  1. QSortFilterProxyModel and get correct data
    By Benecore in forum Qt Programming
    Replies: 1
    Last Post: 5th February 2013, 13:48
  2. Replies: 1
    Last Post: 14th June 2011, 15:50
  3. Replies: 9
    Last Post: 11th April 2011, 10:05
  4. Sort huge data use QSortFilterProxyModel
    By jiaorenjie in forum Qt Programming
    Replies: 0
    Last Post: 16th March 2011, 02:56
  5. QSortFilterProxyModel with changing data
    By kemp in forum Qt Programming
    Replies: 4
    Last Post: 13th September 2010, 07:27

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.