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

A Question about QFile & QTextStream



  • A method loadFile which is a module of a program , a part of a notepad

    void ImgProcessor::loadFile(QString filename)
    {
        printf("file name:%s\n",filename.data());
        QFile file(filename);
        if(file.open(QIODevice::ReadOnly|QIODevice::Text))
        {
            QTextStream textStream(&file);
            while(!textStream.atEnd())
            {
               showWidget->text->append(textStream.readLine());
               // printf("read line \n");  ??????
                //printf("end\n");   ????
            }
        }
    }
    

    who can tell me ,why there are two "printf"
    when i comment it ,nothing different ,
    i can't understand the "printf"



  • printf is just the "C way" of printing to standard output. it does nothing useful for the program, it just prints stuff to the console


Log in to reply