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. QImageReader: File not found
Forum Updated to NodeBB v4.3 + New Features

QImageReader: File not found

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 3 Posters 1.0k Views
  • 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.
  • Christian EhrlicherC Christian Ehrlicher

    @kkgg What is your actual question?

    K Offline
    K Offline
    kkgg
    wrote on last edited by kkgg
    #3

    @Christian-Ehrlicher
    Hello, I developed my own program and used ImageReader to read an image. After I read it many times, it gave me the error "File not found", but my file did exist.
    I try to use Qimage QImageReader and QFile, both show "File not Found"
    I seem to feel that it has something to do with memory, because when I read the n+1th picture, the first picture will produce this phenomenon

    Christian EhrlicherC 1 Reply Last reply
    0
    • K kkgg

      @Christian-Ehrlicher
      Hello, I developed my own program and used ImageReader to read an image. After I read it many times, it gave me the error "File not found", but my file did exist.
      I try to use Qimage QImageReader and QFile, both show "File not Found"
      I seem to feel that it has something to do with memory, because when I read the n+1th picture, the first picture will produce this phenomenon

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #4

      @kkgg you should show some code. Best a minimal, compileable example.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      K 1 Reply Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

        @kkgg you should show some code. Best a minimal, compileable example.

        K Offline
        K Offline
        kkgg
        wrote on last edited by kkgg
        #5

        @Christian-Ehrlicher

        QImage pic = QImage(i);
               pic =  pic.scaled(200, 200, Qt::KeepAspectRatio, Qt::FastTransformation);
               QLabel *m_label = new QLabel(this);
               m_label->setPixmap(QPixmap::fromImage(pic));
        ui->tableWidget->setCellWidget(count , 1, cl_label);
        

        I guess it's not a code problem. I just loaded a picture and put it into a QLabel, and then put the QLabel into QTableWIdget. After reading about 80 pictures, the first one could not be read. I try to find the error with QImageReader, it says "File not found",
        tried using QImageReader::setAllocationLimit(8192);, which can increase the number that can be read

        Christian EhrlicherC JonBJ 2 Replies Last reply
        0
        • K kkgg

          @Christian-Ehrlicher

          QImage pic = QImage(i);
                 pic =  pic.scaled(200, 200, Qt::KeepAspectRatio, Qt::FastTransformation);
                 QLabel *m_label = new QLabel(this);
                 m_label->setPixmap(QPixmap::fromImage(pic));
          ui->tableWidget->setCellWidget(count , 1, cl_label);
          

          I guess it's not a code problem. I just loaded a picture and put it into a QLabel, and then put the QLabel into QTableWIdget. After reading about 80 pictures, the first one could not be read. I try to find the error with QImageReader, it says "File not found",
          tried using QImageReader::setAllocationLimit(8192);, which can increase the number that can be read

          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #6

          I don't see where you load an image here or is 'i' a string? You should check with QFile::exists () if the file really exists. QImageReader does not do something special. It simply opens the file with QFile so I doubt there is an error in there. Simplify your code and create a minimal compileable example or the problem goes away and you found your bug.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          1
          • K kkgg

            @Christian-Ehrlicher

            QImage pic = QImage(i);
                   pic =  pic.scaled(200, 200, Qt::KeepAspectRatio, Qt::FastTransformation);
                   QLabel *m_label = new QLabel(this);
                   m_label->setPixmap(QPixmap::fromImage(pic));
            ui->tableWidget->setCellWidget(count , 1, cl_label);
            

            I guess it's not a code problem. I just loaded a picture and put it into a QLabel, and then put the QLabel into QTableWIdget. After reading about 80 pictures, the first one could not be read. I try to find the error with QImageReader, it says "File not found",
            tried using QImageReader::setAllocationLimit(8192);, which can increase the number that can be read

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #7

            @kkgg
            Please start by following @Christian-Ehrlicher's instructions.

            However, FWIW, you/ @Christian-Ehrlicher might like to read https://forum.qt.io/topic/68238/qimagereader-file-not-found.

            After a few clicks Qimagereader return a "File not found" error even if the image exists (the image is the same).

            all images is loaded correctly, but after few clicks it doesn't work anymore.

            That is from 2016, yet apparently reports this "strange" behaviour. It did not seem to be resolved.

            Is this a timing thing for loading rapidly? Once it goes wrong and says "file not found", if you try to load again does that work or once it is in this state does it never load?

            K 1 Reply Last reply
            0
            • JonBJ JonB

              @kkgg
              Please start by following @Christian-Ehrlicher's instructions.

              However, FWIW, you/ @Christian-Ehrlicher might like to read https://forum.qt.io/topic/68238/qimagereader-file-not-found.

              After a few clicks Qimagereader return a "File not found" error even if the image exists (the image is the same).

              all images is loaded correctly, but after few clicks it doesn't work anymore.

              That is from 2016, yet apparently reports this "strange" behaviour. It did not seem to be resolved.

              Is this a timing thing for loading rapidly? Once it goes wrong and says "file not found", if you try to load again does that work or once it is in this state does it never load?

              K Offline
              K Offline
              kkgg
              wrote on last edited by kkgg
              #8

              @JonB @Christian Ehrlicher "i" is a path, an actual path. I am sure it exists, but using QFile::exists () shows that it does not exist.

              fileDialog.getOpenFileNames(this,"OpenImage","", "Files(*.jpg);;Files(*.png)");
              

              This is how I get the path
              04bfa4a1-0211-4e02-9110-8d2c6f747db6-image.png

              JonBJ 2 Replies Last reply
              0
              • K kkgg

                @JonB @Christian Ehrlicher "i" is a path, an actual path. I am sure it exists, but using QFile::exists () shows that it does not exist.

                fileDialog.getOpenFileNames(this,"OpenImage","", "Files(*.jpg);;Files(*.png)");
                

                This is how I get the path
                04bfa4a1-0211-4e02-9110-8d2c6f747db6-image.png

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #9

                @kkgg said in QImageReader: File not found:

                I am sure it exists, but using QFile::exists () shows that it does not exist.

                If QFile::exists() says it does not then it does not. What exactly is the path you are using?

                K 1 Reply Last reply
                1
                • JonBJ JonB

                  @kkgg said in QImageReader: File not found:

                  I am sure it exists, but using QFile::exists () shows that it does not exist.

                  If QFile::exists() says it does not then it does not. What exactly is the path you are using?

                  K Offline
                  K Offline
                  kkgg
                  wrote on last edited by kkgg
                  #10

                  @JonB I'm sure it exists, because when I don't read n+1 pictures, the first one will not disappear.

                  I guess it has something to do with memory, because when I use QImageReader::setAllocationLimit(8192), the number of Qimages that can be read will increase. The version I use is Qt6.6, and my development environment is Android.

                  The fuzzy part is Chinese, and the road Jin is a fixed string. I used fileDialog.getOpenFileNames(this,"OpenImage","", "Files(.jpg);;Files(.png)"); to get it string

                  1 Reply Last reply
                  0
                  • K kkgg

                    @JonB @Christian Ehrlicher "i" is a path, an actual path. I am sure it exists, but using QFile::exists () shows that it does not exist.

                    fileDialog.getOpenFileNames(this,"OpenImage","", "Files(*.jpg);;Files(*.png)");
                    

                    This is how I get the path
                    04bfa4a1-0211-4e02-9110-8d2c6f747db6-image.png

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by JonB
                    #11

                    @kkgg
                    Hmm, I know nothing about Android, but this may be relevant. Maybe there is an Android issue over time? I don't suppose you can copy the file to somewhere non-Android to check? Probably not, this path means you are running under Android and have access only to its filing system?

                    Please also make 100% clear: you have fuzzed-out some of the filename for privacy, fair enough. But does that blanked-out area contain anything about a "counting i" you mention, so it varies, or is it a fixed string?

                    I guess it has something to do with memory, because when I use QImageReader::setAllocationLimit(8192), the number of Qimages that can be read will increase.

                    Ah, well, isn't that what you have to do then if you want to read more than 80 or whatever? Even if you are passing the same path I would guess that a separate image must be created/stored on each call, since, for example, code would not know whether the content had changed so presumably cannot "share" the resulting image.

                    Having said that, I read QImageReader::setAllocationLimit() as a limit on one call to load one image, not some "cache" applicable across all images loaded.

                    I still find it hard to believe that QFile::exists() sometimes returns false. Unless it's an Android issue.

                    K 1 Reply Last reply
                    0
                    • JonBJ JonB

                      @kkgg
                      Hmm, I know nothing about Android, but this may be relevant. Maybe there is an Android issue over time? I don't suppose you can copy the file to somewhere non-Android to check? Probably not, this path means you are running under Android and have access only to its filing system?

                      Please also make 100% clear: you have fuzzed-out some of the filename for privacy, fair enough. But does that blanked-out area contain anything about a "counting i" you mention, so it varies, or is it a fixed string?

                      I guess it has something to do with memory, because when I use QImageReader::setAllocationLimit(8192), the number of Qimages that can be read will increase.

                      Ah, well, isn't that what you have to do then if you want to read more than 80 or whatever? Even if you are passing the same path I would guess that a separate image must be created/stored on each call, since, for example, code would not know whether the content had changed so presumably cannot "share" the resulting image.

                      Having said that, I read QImageReader::setAllocationLimit() as a limit on one call to load one image, not some "cache" applicable across all images loaded.

                      I still find it hard to believe that QFile::exists() sometimes returns false. Unless it's an Android issue.

                      K Offline
                      K Offline
                      kkgg
                      wrote on last edited by
                      #12

                      @JonB I have also considered whether it is an issue with Android permissions, but I don’t know where to get the answer.

                      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