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

Timestamp of saved Pixmap wrong



  • Hello,
    if have a folder with png's and delete them with the following code:

    QDir dir(path, { "*.png" });	
    	for (const QString & filename : dir.entryList()) {
    		dir.remove(filename);
    	}
    

    After that I create new pixmap png's in the following way:
    (images have the same name)

    QPixmap pixmap;
    pixmap.save(fileName, "PNG");
    

    As a result the images are deleted, the new images are written, but the
    timestamp of the new images are wrong. Some (not all) have the timestamp of
    the pictures before the deletion.
    Its the same for windows 7 and windows 10. It seems, its a windows problem but it confuses the user.

    What is the way of doing this right? What could be a possible workaround?



  • @TauCeti
    Very odd! Try putting in a QTimer with a delay (say several seconds) after the file removals before the re-save. Report back whether that fixes the issue and we'll take it from there?


  • Lifetime Qt Champion

    @TauCeti said in Timestamp of saved Pixmap wrong:

    but the
    timestamp of the new images are wrong

    What timestamp do you mean? Creation time? Modification time? Last access time?



  • Creation time is the "old" time, modification time is the "new" time.
    In the Explorer, the "old" time is displayed.

    A new aspect: this only seems to affect Windows 7, not Windows 10.


Log in to reply