Important: Please read the 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
    defining the flags.

    Is this something QT specific ?

    QStringList lines;
    // QFile file;
    QFile file( "file.txt" );
    // OpenMode flags
    if ( 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;

  • @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-

    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