Results 1 to 20 of 20

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

  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
    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?

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

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

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

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

  15. #15
    Join Date
    Dec 2007
    Posts
    27
    Thanks
    1
    Thanked 4 Times in 3 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

    Its as if the view doesn't use data() to access the model sometimes.
    No, you are right! Sometimes the view does some voodoo magic.
    However, can we close this nasty thread now?

  16. #16
    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
    Do you know of a reason why setRowHidden would break it?
    I don't know, but going through the bug reports I found this bug:
    http://bugreports.qt.nokia.com/browse/QTBUG-7537

    Does this describe what you experience?
    If so, try Qt-4.7.0, as this bug should be fixed in 4.7
    Last edited by tbscope; 25th August 2010 at 05:57.

  17. #17
    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
    I don't know, but going through the bug reports I found this bug:
    http://bugreports.qt.nokia.com/browse/QTBUG-7537

    Does this describe what you experience?
    If so, try Qt-4.7.0, as this bug should be fixed in 4.7
    It might be, but even if its fixed, QSortFilterProxy is too slow for me to use and the bug itself comes from the poor design of the model/view. Even if they fix it in the QSortFilterProxy, whatever is wrong with the underlying Qt stuff might still cause me problems if I don't use QSortFilterProxy. I like that that same assignee "Olivier Goffart" ignored my bug report and gave me crap about it which is partly why I'm so angry about all this, and yet there are bugs with it he didn't think to mention.

    This project I work on was started in Qt 3 and I'm the only developer left so I think I'm going to just wait until I get a chance and move it away from Qt. This list view stuff is so incredibly simple and that they've screwed it up... thanks anyway. I didn't expect a solution but I was hoping someone else had even tried to get a fast sort working who could commiserate with me.

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

    Well, in the future, for any person you want to contact, be it in a bug report, a forum, etc... please, pretty please, do not start with:
    "Hello, I am God, you suck, your code sucks, I don't expect you to know what I mean so I'm not going to say it. I'm not expecting you to help me, so I'm going to be very rude when you do".

    The only person who comes out as an idiot, is you.

    I'm sure your problem can be solved with the use of Qt. But you need to start listening to the people who want to help you. So I hope that you give this one more try:
    Please provide information on how your data is structured and how you try to sort it via the proxy. I don't want you to tell me the model/view classes are poorly designed and I don't want you to tell me I suck (I know I do). Please, give the necessary information to actually help you.

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

    This blog might be interesting for you:
    http://steveire.wordpress.com/

  20. #20
    Join Date
    Nov 2010
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

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

    peterius确实比较粗鲁,æ ¾å¾—è€„è€‹è€å¿ƒ,ä¸è¿ ‡æœ¬åº§è¿˜æ˜¯è¦æ„Ÿè°¢ä» –.å› ä¸ºä»–æ— æ„ä¸*帮 æœ¬åº§è§£å†³äº†ä¸€ä¸ªé— ®é¢˜,é‚£å°±æ˜¯è®©æœ¬åº§çŸ ¥é“了setRowHiddenè¿™ä¸ªå‡½æ •°,本座今天在网上 ‰¾äº†å¥½ä¹…,è¦çš„å°±æ˜ ¯è¿™ä¸ªä¸œè¥¿.
    Last edited by hxcan; 25th November 2010 at 08:53. Reason: spelling corrections
    太极美术工程师师? ?•¿
    http://stupidbeauty.com/Blog

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.