[Qt] Problem mit QTextStream und QFile



  • Hi!

    Ich hoffe, ich kann das Problem hier posten, da ihr ja nur ein MFC und kein Qt-Forum habt:

    #include <qtextstream.h>
    #include <qfile.h>
    #include <qstring.h>
    
    QString content = "";
    QFile f(files[i]);
    if (f.open( IO_ReadOnly ))
    {
    	QTextStream fileStream (&f); // Endlosschleife
    	while (!fileStream.atEnd());
    	{
    		content += fileStream.readLine() + "\n";
    	}
    	f.close();
    }
    QMessageBox::information(this, "content", content);
    

    Warum komme ich an der gekennzeichneten Stelle auf eine Endlosschleife? Es ist egal, welche Textdatei ich öffnen will. Kennt sich hier jemand mit Qt aus?

    MfG



  • Saiyaman schrieb:

    ...
    while (!fileStream.atEnd()); // <- mach das semikolon weg!
    ...
    

    😃


Anmelden zum Antworten