Results 1 to 20 of 20

Thread: has anyone gotten a subclassed item view model to work with a custom sort and filter?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2010
    Posts
    9
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question has anyone gotten a subclassed item view model to work with a custom sort and filter?

    I've been messing with this for a year and Qt irc channel on freenode is worthless, the Qt bug people are worthless. I'm not even going to bother to describe what I've tried so far unless somebody who has actually done a custom sort filter is out there and can say that its possible. I just think the Qt item view/model is poorly designed and that its not possible.

    But just in case, I thought I'd ask. I've spent at least a year of aggravation trying to get this to work so PLEASE don't flame me, don't ask me silly questions. But if you've actually subclassed the model/view framework with a custom sort, then I'd love to hear about it.

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: has anyone gotten a subclassed item view model to work with a custom sort and fil

    Please provide the source code of your latest or best attemt. Then we will go from there.
    I can assure you that it is possible.

  3. #3
    Join Date
    Feb 2010
    Posts
    9
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: has anyone gotten a subclassed item view model to work with a custom sort and fil

    tbscope have you actually done a subclassed custom sort and filter?

  4. #4
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: has anyone gotten a subclassed item view model to work with a custom sort and fil

    peterius,

    If you actually WANT help, please answer my question above with YOUR attempt on how to do it.
    You must have one since you're very upset of it not working. Well, post it and I'll go over it and see where the problems are.

  5. #5
    Join Date
    Feb 2010
    Posts
    9
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: has anyone gotten a subclassed item view model to work with a custom sort and fil

    I am so sick of people asking to post source code. That NEVER helps unless your a CS student learning how to program. Its not a damn typo. If you haven't subclassed the item model and tried to write a custom sort than it doesn't matter if I post ten pages of source code, you won't know what I'm talking about and just like the last fifty people I've talked to you won't be able to suggest anything.

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: has anyone gotten a subclassed item view model to work with a custom sort and fil

    That NEVER helps unless your a CS student learning how to program.
    How wrong can one person with attitude be.

  7. #7
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: has anyone gotten a subclassed item view model to work with a custom sort and fil

    Quote Originally Posted by peterius View Post
    I am so sick of people asking to post source code. That NEVER helps unless your a CS student learning how to program. Its not a damn typo. If you haven't subclassed the item model and tried to write a custom sort than it doesn't matter if I post ten pages of source code, you won't know what I'm talking about and just like the last fifty people I've talked to you won't be able to suggest anything.
    Please peterius, you get me very wrong. I am very willing to help you.
    It won't matter what I say to you. I can tell you that I did this a couple of times alread and it always worked and you will not believe me unless I post some source code. I can understand this, but since other people might have the same problem, it would be so much nicer if you posted your source code with the problem so the solution can be posted in the same forum thread.

    Please, pretty please, post your source code. Let me at least help you.
    Last edited by tbscope; 20th August 2010 at 06:16.

  8. #8
    Join Date
    Feb 2010
    Posts
    9
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: has anyone gotten a subclassed item view model to work with a custom sort and fil

    I very very much doubt you can help me if you can't even read my posts. You have yet to say that you've actually done a custom sort as well as a custom filter without using the useless QSortProxyFilter class. I asked you in earlier posts and you didn't say anything.

  9. #9
    Join Date
    Oct 2009
    Location
    Mexico
    Posts
    81
    Thanks
    6
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: has anyone gotten a subclassed item view model to work with a custom sort and fil

    to peterius: read the docs.
    you can easily found a complete example of how do custom sort using model/view http://doc.trolltech.com/4.5/itemvie...ltermodel.html .

    and if you really spend one year try to resolve this problem, leave the programming and work in something else. telemarketing maybe is a good option
    Last edited by ecanela; 23rd August 2010 at 01:27. Reason: try to make the comment more friendly

  10. #10
    Join Date
    Feb 2010
    Posts
    9
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: has anyone gotten a subclassed item view model to work with a custom sort and fil

    Quote Originally Posted by ecanela View Post
    to peterius: read the docs.
    you can easily found a complete example of how do custom sort using model/view http://doc.trolltech.com/4.5/itemvie...ltermodel.html .

    and if you really spend one year try to resolve this problem, leave the programming and work in something else. telemarketing maybe is a good option
    This is more what I expect what from people. All I wanted was the vain hope that somebody on this forum has written a custom sort to replace Qt's item view sort. But instead I get the automatic "post some source code so we can ask inane questions" and then the flames from people like this.

    Qt's custom sort filter model is garbage. Its way too slow to use and so I've subclassed it. I don't expect help from this forum because I don't think there's anyone who has actually subclassed the model and written a custom sort that works. I don't think Qt designed the item views well enough to actually do that. If anyone out there has tried this, then they would know what I've been trying to do with it for a year and would maybe have some idea how to work around the Qt internals to get a sort and filter on an item view without using QSortFilterProxy.

    Edit:
    Quote Originally Posted by franz View Post
    Since the question is:

    The answer is:
    Yes.
    Thank you. That's a start. So let's say you override the data() and index() functions and of course sort(). The problem for me is the filtering. Nothing I've tried seems to filter it correctly. The last thing I tried a few weeks ago was using setRowHidden on a subclass of the QTreeView. But this seems to randomly lose the filtering. Is this something your familiar with?
    Last edited by peterius; 23rd August 2010 at 08:34.

  11. #11
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: has anyone gotten a subclassed item view model to work with a custom sort and fil

    Quote Originally Posted by peterius View Post
    Qt's custom sort filter model is garbage. Its way too slow to use and so I've subclassed it.
    The first time I actually understand what your problem is. Was it so hard to say this?

    I don't expect help from this forum because I don't think there's anyone who has actually subclassed the model and written a custom sort that works.
    Your are very correct. This forum contains no users who write Qt code or do model/view programming. We are all stupid. (If you don't get sarcasm, this was it)

    I don't think Qt designed the item views well enough to actually do that.
    I agree that some parts of the Qt item views isn't like I want it to be.

    If anyone out there has tried this, then they would know what I've been trying to do with it for a year and would maybe have some idea how to work around the Qt internals to get a sort and filter on an item view without using QSortFilterProxy.
    How can anyone know what you mean if you don't say what you mean?
    And yes, there's a way to sort your data without a proxy model: sort your data inside the model!

    Thank you. That's a start. So let's say you override the data() and index() functions and of course sort(). The problem for me is the filtering. Nothing I've tried seems to filter it correctly. The last thing I tried a few weeks ago was using setRowHidden on a subclass of the QTreeView. But this seems to randomly lose the filtering. Is this something your familiar with?
    Can you at least, I know it is hard to provide information, give a basic view of your data structure and how and what you want to sort?

    Basically, your model contains the data structure. You can, when you add data for example, sort everything directly in the model. That would, as I think you suggest, make reading the data a lot faster because it doesn't need to be sorted when read. However, adding data can become slower of course. It also will break sorting in multiple views. Suppose you have a two listviews with the same model, you will not be able to sort them differently if you do it in the model directly, that's why proxy models are used.

  12. #12
    Join Date
    Feb 2010
    Posts
    9
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: has anyone gotten a subclassed item view model to work with a custom sort and fil

    Quote Originally Posted by tbscope View Post
    Can you at least, I know it is hard to provide information, give a basic view of your data structure and how and what you want to sort?

    Basically, your model contains the data structure. You can, when you add data for example, sort everything directly in the model. That would, as I think you suggest, make reading the data a lot faster because it doesn't need to be sorted when read. However, adding data can become slower of course. It also will break sorting in multiple views. Suppose you have a two listviews with the same model, you will not be able to sort them differently if you do it in the model directly, that's why proxy models are used.
    Well like I said, the sort isn't the problem. Its that it loses the sorting when I try to filter it with setRowHidden. And I'm wondering if anyone has done this before? Your sarcasm aside, there's a good chance no one has. Do you know of a reason why setRowHidden would break it? Its as if the view doesn't use data() to access the model sometimes.

  13. #13
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: has anyone gotten a subclassed item view model to work with a custom sort and fil

    Quote Originally Posted by peterius View Post
    I very very much doubt you can help me if you can't even read my posts. You have yet to say that you've actually done a custom sort as well as a custom filter without using the useless QSortProxyFilter class. I asked you in earlier posts and you didn't say anything.
    I read your posts better than you can understand them yourself.
    You begin with saying everyone is worthless. Then when some people still do want to help, you say they are worthless too.

    May I give you a tip? Always treat people nice, and you'll get a lot more help.

    Now, when I personally give information, two things can happen:
    1. The person asking the question shows he or she has actually searched how to solve the problem and lets it show (by describing a solution or posting some code), or I understand from the post that the person really doesn't understand a certain concept. In those cases I will be happy to help. In most cases, this is very easy because most things are already explained in the documentation.

    2. The person asking the question shows that he or she does not actively searched for the information himself, or is very blunt (I'm allergic to rude people), or just wants someone to solve his or her problem without spending some effort, then I can only state the obvious.

    You say that you are trying for a year. You certainly must have some example code where things do not work. Please post that code and I WILL, yes, I actually WILL, after all this fuss, help you make it work. How's that for goodwill?

  14. #14
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: has anyone gotten a subclassed item view model to work with a custom sort and fil

    Since the question is:
    has anyone gotten a subclassed item view model to work with a custom sort and filter?
    The answer is:
    Yes.

    As tbscope said: be nice to people if you want them to help you.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

Similar Threads

  1. Replies: 9
    Last Post: 14th February 2013, 19:39
  2. Replies: 1
    Last Post: 24th June 2010, 14:50
  3. Set a filter on a model/view
    By graciano in forum Qt Programming
    Replies: 6
    Last Post: 13th June 2010, 17:07
  4. model.sort(col, Qt::AscendingOrder); does not work.
    By kaushal_gaurav in forum Qt Programming
    Replies: 1
    Last Post: 18th August 2008, 07:18
  5. Filter Proxy Model to Autoupdate View
    By Big Duck in forum Qt Programming
    Replies: 1
    Last Post: 1st June 2006, 20:32

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.