Potch
10th June 2008, 23:03
Hello,
I need to parse a tab delimited (or csv) file and display it in a QTableWidget.
So far, I do it this way :
while (!MyStream.atEnd())
{
General_Interface.MainTable->insertRow(Max_Number_of_Lines+1);
buffer_line = MyStream.readLine();
buffer_list = buffer_line.split(Delimiter);
for (int column = 0; column <= Max_Number_of_Columns; column ++)
{
QTableWidgetItem *Cell_Content = new QTableWidgetItem();
Cell_Content->setText(buffer_list[column]);
General_Interface.MainTable->setItem(Max_Number_of_Lines, column,
Cell_Content);
}
Max_Number_of_Lines++;
}
The problem is that the kind of file I have to parse can contains more than 30 columns and 5000 lines, and in these cases it's awfully slow.
How can I optimize this ?
Is it relevant to use a QTextStream as I did ?
Thanks in advance...
I need to parse a tab delimited (or csv) file and display it in a QTableWidget.
So far, I do it this way :
while (!MyStream.atEnd())
{
General_Interface.MainTable->insertRow(Max_Number_of_Lines+1);
buffer_line = MyStream.readLine();
buffer_list = buffer_line.split(Delimiter);
for (int column = 0; column <= Max_Number_of_Columns; column ++)
{
QTableWidgetItem *Cell_Content = new QTableWidgetItem();
Cell_Content->setText(buffer_list[column]);
General_Interface.MainTable->setItem(Max_Number_of_Lines, column,
Cell_Content);
}
Max_Number_of_Lines++;
}
The problem is that the kind of file I have to parse can contains more than 30 columns and 5000 lines, and in these cases it's awfully slow.
How can I optimize this ?
Is it relevant to use a QTextStream as I did ?
Thanks in advance...