I am creating a function named getExcelFile() to get the contents of the excel file and store it into an array of structures. First I wanted read one line of the csv file and use the delimiter , . Then I want to add the contents to the QStringList and use a for loop to iterate through an array of structures and add the contents into it. Everything is working fine except for the line where it says datalist.append((line.split(','))); Help would be greatly appreciated!
void Widget::getExcelFile(){
//Name of the Qfile object.
//filename is the directory of the file once it has been selected in prompt
QFile thefile(filename);
//QStringList named datalist.
QStringList datalist;
//If the file is successfully open
if (thefile.open(QIODevice::ReadOnly | QIODevice::Text)){
qDebug() << "File opened successfully";
while (!thefile.atEnd()){
QByteArray line = thefile.readLine();
datalist.append((line.split(',')));
}
}
qDebug() << datalist;
ui->textEdit->setPlainText(fileContent);
}