Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Writing and reading from file error
Forum Updated to NodeBB v4.3 + New Features

Writing and reading from file error

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ahmed kato
    wrote on last edited by
    #1

    hii..i have a strange error here and i don't know what is the problem...i write into a file using this code:
    @if(File->open(QIODevice::ReadWrite | QIODevice::Text))
    {
    //File->write("al 7amdlelaah =)");
    QTextStream fout(File);
    for(int i=0;i<Listpointer->size();++i)
    {
    fout<<Listpointer->at(i)<<"\n";

        }
        File->flush();
        File->close();
    }@
    

    and the read from the same file using this code:
    @if(RunFile.open(QIODevice::ReadWrite |QIODevice::Text))
    {
    QStringList list;
    QTextStream in(&RunFile);
    while(!RunFile.atEnd())
    {
    QString line = in.readLine();
    list.append(line);
    }
    ui->listWidget->addItems(list);
    //RunFile->close();
    }@
    the problem that it read only the first line and ignore other lines...i don't know what is the problem thx in advance =)

    Ahmed Kato
    Computer & communications student
    Intern and MSP at Microsoft

    1 Reply Last reply
    0
    • A Offline
      A Offline
      ahmed kato
      wrote on last edited by
      #2

      ok i got my mistake..it is
      @
      While(!in.atEnd())
      @
      :D:D

      [EDIT: fixed code, no bold or other visual formatting, Volker]

      Ahmed Kato
      Computer & communications student
      Intern and MSP at Microsoft

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved