Read data and add it to a chart
- 
@suslucoder said in Read data and add it to a chart: I should use another struct instead of string list, right? You should use what the method to set the data expects. That's why I suggested to read the documentation: it is documented quite clearly. @jsulm ıs there any example that doing exactly what you said? 
- 
@jsulm ıs there any example that doing exactly what you said? @suslucoder I already posted a link to charts examples. 
 For example: https://doc.qt.io/qt-5/qtcharts-temperaturerecords-example.html
 And you still did not tell us what data you actually want to show and what type of chart you need...
- 
Hi 
 Please show one line from the "C:/Users/ilknu/Documents/QFileDemo/abc.txt"
 so we know how data is. else it's impossible to give any hints on how you can show that in a chart.
- 
Hi 
 Please show one line from the "C:/Users/ilknu/Documents/QFileDemo/abc.txt"
 so we know how data is. else it's impossible to give any hints on how you can show that in a chart.@mrjj Here it is 1991 01 213.5 136.9 0.64 220.5 147.6 229.4 205.5 8 17.4 
 1991 02 270.2 167.5 0.62 221.5 147.6 243.0 206.3 10 18.4
- 
@mrjj Here it is 1991 01 213.5 136.9 0.64 220.5 147.6 229.4 205.5 8 17.4 
 1991 02 270.2 167.5 0.62 221.5 147.6 243.0 206.3 10 18.4QString line = read_one_line_from_file(); QStringList list = line.split(QLatin1Char(' '), Qt::SkipEmptyParts); for (const QString &entry : list) { double num = entry.toDouble(); // or `unsigned num = entry.toUInt()` for the first 2 numbers on each line, by the look of it // do whatever is necessary with each `double` number retrieved // such as adding pairs directly to the chart, or building a `QLineSeries`, or whatever }
- 
QString line = read_one_line_from_file(); QStringList list = line.split(QLatin1Char(' '), Qt::SkipEmptyParts); for (const QString &entry : list) { double num = entry.toDouble(); // or `unsigned num = entry.toUInt()` for the first 2 numbers on each line, by the look of it // do whatever is necessary with each `double` number retrieved // such as adding pairs directly to the chart, or building a `QLineSeries`, or whatever }@JonB Thank you. Where should I place the code script? 
- 
@JonB Thank you. Where should I place the code script? @suslucoder said in Read data and add it to a chart: Where should I place the code script? Come on. Place is where you read the data from the file... 
- 
@suslucoder said in Read data and add it to a chart: Where should I place the code script? Come on. Place is where you read the data from the file... @jsulm I know but i have, QString line = in.readLine(); 
 allLines.append(line);
 I couldnt get the idea about it. When i do it i get out of index error .And after doing all this things, how can i add my datas to a chart?
- 
@jsulm I know but i have, QString line = in.readLine(); 
 allLines.append(line);
 I couldnt get the idea about it. When i do it i get out of index error .And after doing all this things, how can i add my datas to a chart?@suslucoder I did this part. After that, how can i add it to a chart? Like the way create a new chart, append series and it goes like this? 
- 
@jsulm I know but i have, QString line = in.readLine(); 
 allLines.append(line);
 I couldnt get the idea about it. When i do it i get out of index error .And after doing all this things, how can i add my datas to a chart?@suslucoder said in Read data and add it to a chart: And after doing all this things, how can i add my datas to a chart? I already provided links to examples several times. "When i do it i get out of index error" - then post your code... 
- 
@suslucoder said in Read data and add it to a chart: And after doing all this things, how can i add my datas to a chart? I already provided links to examples several times. "When i do it i get out of index error" - then post your code... @jsulm ``` 
 QString line = in.readLine();
 allLines.append(line);
 QStringList list = line.split(QLatin1Char(' '), Qt::SkipEmptyParts);
 for(const QString &entry : list) {
 double num = entry.toDouble();
 }
 series->append(num)
 ``
 Says use of undeclared identifier num
- 
Hi 
 You want likeQStringList list = line.split(QLatin1Char(' '), Qt::SkipEmptyParts); for(const QString &entry : list) { double num = entry.toDouble(); series->append(X,Y); // use num for either xor y or both depending on what you want }
- 
Hi 
 You want likeQStringList list = line.split(QLatin1Char(' '), Qt::SkipEmptyParts); for(const QString &entry : list) { double num = entry.toDouble(); series->append(X,Y); // use num for either xor y or both depending on what you want }@mrjj said in Read data and add it to a chart: series->append(num); // add each number from the line This cannot work as QLineSeries does not have such an overload. Currently discussed here. 
- 
@mrjj said in Read data and add it to a chart: series->append(num); // add each number from the line This cannot work as QLineSeries does not have such an overload. Currently discussed here. 
 

