Re: Where to submit a bug?
Re: Where to submit a bug?
What is the bug, by the way?
Re: Where to submit a bug?
Hello,
@kwisp Thanks, this was fast.
@wysota
I changed the 'findfiles' example from the distribution (examples/dialogs/findfiles) to enable sorting (you know: click on the header of a column and the table gets sorted on the content of this particular column).
In the original version file sizes showed up as expected.
In the modified version most (almost all) files have no size any more and the one(s) that do have a size appear to have a wrong value.
The change I made was adding one line into the creation code for the table (see below).
Code:
void Window::createFilesTable()
{
labels << tr("File Name") << tr("Size");
filesTable->setHorizontalHeaderLabels(labels);
filesTable
->horizontalHeader
()->setResizeMode
(0,
QHeaderView::Stretch);
filesTable->verticalHeader()->hide();
filesTable->setShowGrid(false);
// This line added
filesTable->setSortingEnabled(true);
connect(filesTable, SIGNAL(cellActivated(int, int)),
this, SLOT(openFileOfItem(int, int)));
}
This is on Windows XP using the stand-alone Qt Creator 1.2.1 (based on Qt 4.5.2).
I'll go and report it.
Best regards
Helmut Giese
Re: Where to submit a bug?
I could reproduce this.
When the new line filesTable->setSortingEnabled(true); is moved after the call of findFiles() (line 132) the file sizes are displayed correctly.
So the sorting does weird things to table content.
But honestly I believe that the problem lies not in Qt itself, but in the example.
The example inserts a row and afterwards fills file name and file size to the row.
When sorting is enabled the row number that showFiles() uses is not the number where the row was inserted. The sorting moved the row.
If the example should work it should either sort after inserting all rows (see above) or better take care of where QTableWidgetItems are inserted.
Re: Where to submit a bug?
This is not a bug in Qt. This is the fault of architecture of the example. If you disable sorting temporarily during the run of the loop in Window::showFiles(), everything will be correct. Analyze the loop to see why.
Re: Where to submit a bug?
Hi there,
@Boron Thanks for trying it out and for the analysis. If I disable/enable sorting around the filling operation everything works. This "bug" has cost me - no I won't tell in public.
@wysota I wonder: If there were an 'append' method, adding rows and sorting them would not step on each others feet - but such a method does not seem to exist.
Another question (if I may): When sorting I want _all_ directories always shown before _any_ files so I need some kind of "custom sort". I wonder: Is a QTableWidget then the right choice?
Any link would be greatly appreciated.
Best regards
Helmut Giese
Re: Where to submit a bug?
You can subclass QSortFilterProxyModel and reimplement lessThan().
Re: Where to submit a bug?
Quote:
Originally Posted by
hgiese
@wysota I wonder: If there were an 'append' method, adding rows and sorting them would not step on each others feet - but such a method does not seem to exist.
But it has nothing to do with having a method to append some data. The "problem" is that if you change the text in the table, it immediately gets resorted and the row will go elsewhere. To overcome it it is enough to hold a pointer to the item you are operating on and use this pointer to enter data.
The example is simply very trivial with a single goal of proving some point. It's not a general purpose foul-proof and fool-proof full-blown framework for everything. If you fell into this trap it means that you probably don't fully understand what is going on in the framework. Otherwise you wouldn't have copied the example but instead would write the code from scratch to suit your needs.
Quote:
Another question (if I may): When sorting I want _all_ directories always shown before _any_ files so I need some kind of "custom sort". I wonder: Is a QTableWidget then the right choice?
It's as right and as wrong choice as any other when it comes to sorting. When your application grows more complex you will probably have to switch to using QTableView with a real model.
Re: Where to submit a bug?
Hi wysota,
Quote:
If you fell into this trap it means that you probably don't fully understand what is going on in the framework. Otherwise you wouldn't have copied the example but instead would write the code from scratch to suit your needs.
spot on!
Yes, I am completely new to Qt and a tool of such complexity imposes a - probably rather steep - learning curve. So one takes an example which _looks_ like it does something close to what one wants to achieve and then sort of stumbles forward.
It's a bit of a catch-22: If I were familiar with Qt I wouldn't need the examples. Since I am not they are a helpful source of insight into the inner workings - but I am of course not yet in a position to really judge their suitability.
Anyway, thanks a lot for your help. Let's close this thread since it's topic is rather misleading now.
Best regards
Helmut Giese
Re: Where to submit a bug?
If your are a commercial license holder you can use the Customer Portal
Best Regards
NoRulez
Re: Where to submit a bug?
Quote:
If your are a commercial license holder you can use the Customer Portal
No, I'm just a poor guy ...