PDA

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



peterius
17th August 2010, 02:56
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.

tbscope
17th August 2010, 06:44
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.

peterius
17th August 2010, 18:32
tbscope have you actually done a subclassed custom sort and filter?

tbscope
18th August 2010, 06:36
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.

peterius
19th August 2010, 22:06
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.

ChrisW67
20th August 2010, 02:32
That NEVER helps unless your a CS student learning how to program.
How wrong can one person with attitude be.

tbscope
20th August 2010, 07:11
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.

peterius
22nd August 2010, 20:31
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.

ecanela
22nd August 2010, 21:44
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/itemviews-customsortfiltermodel.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

tbscope
23rd August 2010, 06:40
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?

franz
23rd August 2010, 07:13
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.

peterius
23rd August 2010, 09:30
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/itemviews-customsortfiltermodel.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:

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?

tbscope
23rd August 2010, 11:11
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.

peterius
24th August 2010, 20:48
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.

yakin
24th August 2010, 23:19
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?

tbscope
25th August 2010, 06:50
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

peterius
27th August 2010, 02:54
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.

tbscope
27th August 2010, 06:54
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.

tbscope
27th August 2010, 07:25
This blog might be interesting for you:
http://steveire.wordpress.com/

hxcan
25th November 2010, 09:52
peterius确实比较粗鲁,æ ¾å¾—è€„è€‹è€å¿ƒ,ä¸è¿ ‡æœ¬åº§è¿˜æ˜¯è¦æ„Ÿè°¢ä» –.å› ä¸ºä»–æ— æ„ä¸*帮 æœ¬åº§è§£å†³äº†ä¸€ä¸ªé— ®é¢˜,é‚£å°±æ˜¯è®©æœ¬åº§çŸ ¥é“了setRowHiddenè¿™ä¸ªå‡½æ •°,本座今天在网上 ‰¾äº†å¥½ä¹…,è¦çš„å°±æ˜ ¯è¿™ä¸ªä¸œè¥¿.