Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

error " use of undeclared idetifier IO_ReadOnly ..."



  • Using this example I am obviously missing "OpenMode flags"

    This resource does no help
    https://www.digitalfanatics.org/projects/qt_tutorial/chapter08.html
    defining the flags.

    Is this something QT specific ?

    QStringList lines;
    // QFile file;
    QFile file( "file.txt" );
    // OpenMode flags
    // file.open()
    if ( file.open( IO_ReadOnly ) ) {
    QTextStream stream( &file );
    QString line;
    int i = 1;
    while ( !stream.atEnd() ) {
    line = stream.readLine(); // line of text excluding '\n'
    printf( "%3d: %s\n", i++, line.latin1() );
    lines += line;
    }
    file.close();
    }



  • @AnneRanch
    If you look at the foot of the example page you quote you will see Copyright (c) 2002-2004 by Johan Thelin (e8johan -at- digitalfanatics.org).

    You must not use such an old example, it was written for Qt 3. Many things have changed since then. The newer constant for IO_ReadOnly is QIODevice::ReadOnly, which should make this compile, but I strongly suggest you simply ditch this example code as there may be other problems (e.g. I don't think your line.latin1() will work) or deprecated code.


Log in to reply