Search code examples
c++qtqtableviewqlistqtabwidget

how to can insert the value from txt file to the Qlist and work with QTablewideget


how i can to insert the value from txt file in to the Qlist...

    QList<QString> list_StRead;
    list_StRead.insert();

i can sorting txt file ... its mean that my file is a line by line... than after the insert to the Qlist i want to write in to Qtabelewidget... how i must to do?? u must to be completely understand.. see the img file .. enter image description here

tnx for all....


Solution

  • #include <QStringList>
    #include <QFile>
    #include <QTextStream>
    
    int main(void)
    {
      QFile data("data.txt");
      QTextStream stream(&data);
      QStringList strings(stream.readAll().split("\n")); // or another split character
    }