Here is th code:
This section creates the main treeWidget....
treeWidget->setMinimumSize(650, 400); // int width, int height
treeWidget->setColumnCount(3);
treeWidget->setAlternatingRowColors(true);
headerLabels << "System Error Messages " << "Time Stamp: HH:MM:SS" << "Parameter";
treeWidget->setHeaderLabels(headerLabels);
treeWidget->resizeColumnToContents(1);
treeWidget->setColumnWidth(0, 325);
treeWidget->setWindowTitle(tr("Error Time Stamps"));
treeWidget
->setWindowIcon
(QIcon(":/images/My.ico"));
QTreeWidget *treeWidget = new QTreeWidget();
treeWidget->setMinimumSize(650, 400); // int width, int height
treeWidget->setColumnCount(3);
treeWidget->setAlternatingRowColors(true);
QStringList headerLabels;
headerLabels << "System Error Messages " << "Time Stamp: HH:MM:SS" << "Parameter";
treeWidget->setHeaderLabels(headerLabels);
treeWidget->resizeColumnToContents(1);
treeWidget->setColumnWidth(0, 325);
treeWidget->setWindowTitle(tr("Error Time Stamps"));
treeWidget->setWindowIcon(QIcon(":/images/My.ico"));
To copy to clipboard, switch view to plain text mode
This section parses out the error messages. Note that I have about 20 of these, similar in nature, but are used to parse out device specific error codes.
tmuRoot->setText(0, tr("TMU Errors"));
treeWidget->addTopLevelItem(tmuRoot);
for(int i = 0; i<error.size();++i)
{
infoTmu
->setIcon
(0,
QIcon(":/images/12-em-cross_12x12.png"));
infoTmu->setText(0, error[i]);
infoTmu->setText(1, time[i]);
infoTmu->setToolTip(0, ttTmu[i]);
infoTmu->setText(2,pTmu[i]);
tmuRoot->addChild(infoTmu);
}
treeWidget->show();
QTreeWidgetItem *tmuRoot = new QTreeWidgetItem(treeWidget); // TMU Errors - parent
tmuRoot->setText(0, tr("TMU Errors"));
treeWidget->addTopLevelItem(tmuRoot);
for(int i = 0; i<error.size();++i)
{
QTreeWidgetItem* infoTmu = new QTreeWidgetItem();
infoTmu->setIcon(0, QIcon(":/images/12-em-cross_12x12.png"));
infoTmu->setText(0, error[i]);
infoTmu->setText(1, time[i]);
infoTmu->setToolTip(0, ttTmu[i]);
infoTmu->setText(2,pTmu[i]);
tmuRoot->addChild(infoTmu);
}
treeWidget->show();
To copy to clipboard, switch view to plain text mode
The treeWidget data is collected from an error file, which can be of any length, from as little as 256 bytes, up to 5 Mb. The error file is read into and stored inside four seperate QVectors. If the error file is small, the time stamp treeWidget is parsed rather quickly and has no issues. But if the error file is quite large, (the one I am using for testing is 3 Mb in size....) the treeWidget takes quite a bit of time to fill itself up with all the values, and then when completeted, is shown to the user. The other issue is when a parent is expanded, using the vertical scroll bar to see all the error timestamps is pretty much useless as it takes several seconds to refresh the view, but that is another issue all together.....
One section of errors, in this case anyways, has just over 300,000 child items - and this of course is the bottleneck. This is not normally the case as most child items have maybe a dozen or less errors, but we do get the odd case of a device that has been running for 24 hours or more, generating a large amount of errors.
My original question is how to present some indication to the user that the program is actually doing something in the background once they have clicked on the button to show the timestamps?
Thanks!
Bookmarks