Skip to content
  • 0 Votes
    23 Posts
    2k Views
    JonBJ

    @mvsri said in QT QImage Read From Error:

    image_path is nothing but a QString which stores the path to a bmp image in a folder. the path is static it doesn't change.

    I know that! My question is about the content of that file.

    I don't know whether the image writing is finished or not. that's why i used QFile exists to check if the file is created or not and read the image if the path exists.

    But that doesn't tell you anything about whether it has started but not finished writing to that file, does it? (Unless you are relying on Windows or something not allowing a file to satisfy "exists" until it has been closed, which I would see as dodgy in the extreme.) In which case, you will read in an incomplete image file, maybe that's why you have "black" at the bottom? At least put in a qDebug() << image.sizeInBytes() after loading it (though I'm not sure if that's reliable)....

    QFile::remove(image_path);

    It gets worse! This, or renaming: how do you know that at the instant you execute this the camera has not re-started writing to that file for the next capture, and you are (trying to) removing/renaming a file while it is being written anew?

    Is your camera-image-capture-write-to-file a separate process from your code? How do you know when the capture has started/finished writing to the file?

  • 0 Votes
    2 Posts
    394 Views
    JonBJ

    @CybeX
    Well, the debugger shows a as "<not accessible>", so unless its value has been optimized out that seems to be the cause of the SEGV. I admit I don't know how/why, assuming you only put items into fileInfoImageList via the code you show.

    I would start by just checking you can visit/print out all the QFileInfos in your lists before you start the std::sort()?

    I would also force a complete rebuild just to make sure. The placement of the debug breakpoint on line #319 which is blank looks odd to me, it's not supposed to do that....

  • 0 Votes
    9 Posts
    2k Views
    SGaistS

    Hi,

    QAbstractListModel