PDA

View Full Version : What is *.cht file?



babygal
15th December 2010, 08:02
What is *.cht file? And when do I use this type of file and what is the main purpose?

franz
15th December 2010, 08:14
Where did you come across this file type?

babygal
15th December 2010, 08:32
In Qt Chart example.

Please see the link below:
http://doc.trolltech.com/latest/itemviews-chart-chart-qrc.html


Main page:
http://doc.trolltech.com/latest/itemviews-chart.html

franz
15th December 2010, 15:06
It's nothing special. The pie chart data can be stored to file using the demo. The file extension has been set to cht. In practice it could also be a .txt, .dat, .chart, .whatever.

The following code describes the file format:


do {
line = stream.readLine();
if (!line.isEmpty()) {

model->insertRows(row, 1, QModelIndex());

QStringList pieces = line.split(",", QString::SkipEmptyParts);
model->setData(model->index(row, 0, QModelIndex()), pieces.value(0));
model->setData(model->index(row, 1, QModelIndex()), pieces.value(1));
model->setData(model->index(row, 0, QModelIndex()), QColor(pieces.value(2)), Qt::DecorationRole);
row++;
}
} while (!line.isEmpty());


Each line contains three fields, separated by a space. The first field is the name, second is the quantity and the third is the color.

babygal
20th December 2010, 07:59
do {
line = stream.readLine();
if (!line.isEmpty()) {

chartmodel->insertRows(row, 1, QModelIndex());
QStringList pieces ;
pieces = line.split(tr(","), QString::SkipEmptyParts);
chartmodel->setData(model->index(row, 0, QModelIndex()),pieces.value(0));
chartmodel->setData(model->index(row, 1, QModelIndex()),pieces.value(1));
chartmodel->setData(model->index(row, 0, QModelIndex()),QColor(pieces.value(2)), Qt::DecorationRole);
row++;
}
} while (!line.isEmpty());
I copy paste the above code in my application but it causes runtime error at line #8.

S.O.S

SixDegrees
20th December 2010, 08:11
It's a custom file format written for the sole purpose of supporting the example program. Unless "my application" is the example program, with all the supporting code required to manipulate such files, it isn't going to work. You can't just blindly copy chunks of code out of one program, paste them into an unrelated program, and expect them to work.