So I added a debug to the while statement, to see what is hold in vectorOfVectorsOfStrings
QVector(QVector("19"),
QVector("sunshine live"),
QVector("0x1234"),
QVector("19"),
QVector("dlf kultur"),
QVector("0x9876"),
QVector("19"),
QVector("dlf1 kultur"),
QVector("0x9876"),
QVector("19"),
QVector("dlf2 kultur"),
QVector("0x9876"),
QVector("19"),
QVector("dlf3 kultur"),
QVector("0x9876"),
QVector("19"),
QVector("dlf4 kultur"),
QVector("0x9876"),
QVector("19"),
QVector("dlf5 kultur"),
QVector("0x9877"))
QVector(QVector("19"), QVector("sunshine live"), QVector("0x1234"), QVector("19"), QVector("dlf kultur"), QVector("0x9876"), QVector("19"), QVector("dlf1 kultur"), QVector("0x9876"), QVector("19"), QVector("dlf2 kultur"), QVector("0x9876"), QVector("19"), QVector("dlf3 kultur"), QVector("0x9876"), QVector("19"), QVector("dlf4 kultur"), QVector("0x9876"), QVector("19"), QVector("dlf5 kultur"), QVector("0x9877"))
To copy to clipboard, switch view to plain text mode
I expected something like
QVector(QVector("19", "sunshine live", "0x1234"), QVector("19", "dlf kultur", "0x9876")........)
To copy to clipboard, switch view to plain text mode
Am I wrong and it already runs well, or am I right?
Added after 1 10 minutes:
Just to complete it, solution:
void MainWindow::on_pushButton_clicked()
{
QMessageBox::warning(this,
"..",
"keine datei gefunden");
return;
}
QVector<QVector<QString>> vectorOfVectorsOfStrings;
QVector<QString> zeile;
while (!in_file.atEnd()) {
text = in_file.readLine();
qDebug() << text;
qDebug() << split_text;
QVector<QString> zeile;
zeile.push_back(split_text.at(0));
zeile.push_back(split_text.at(1));
zeile.push_back(split_text.at(2));
qDebug() << zeile;
vectorOfVectorsOfStrings.push_back(zeile);
qDebug() << vectorOfVectorsOfStrings;
}
file.close();
for(int i = 0; i < vectorOfVectorsOfStrings.size(); i++)
{
ui->listWidget->addItem(vectorOfVectorsOfStrings[i][1]);
}
}
void MainWindow::on_pushButton_clicked()
{
QFile file(pfad);
if(!file.open(QFile::ReadOnly | QFile::Text)){
QMessageBox::warning(this,"..","keine datei gefunden");
return;
}
QTextStream in_file(&file);
QString text;
QVector<QVector<QString>> vectorOfVectorsOfStrings;
QVector<QString> zeile;
while (!in_file.atEnd()) {
text = in_file.readLine();
qDebug() << text;
QStringList split_text = text.split(",");
qDebug() << split_text;
QVector<QString> zeile;
zeile.push_back(split_text.at(0));
zeile.push_back(split_text.at(1));
zeile.push_back(split_text.at(2));
qDebug() << zeile;
vectorOfVectorsOfStrings.push_back(zeile);
qDebug() << vectorOfVectorsOfStrings;
}
file.close();
for(int i = 0; i < vectorOfVectorsOfStrings.size(); i++)
{
ui->listWidget->addItem(vectorOfVectorsOfStrings[i][1]);
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks