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. Timestamp of saved Pixmap wrong

Timestamp of saved Pixmap wrong

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 245 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.
  • T Offline
    T Offline
    TauCeti
    wrote on last edited by
    #1

    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?

    JonBJ jsulmJ 2 Replies Last reply
    0
    • T TauCeti

      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?

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

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

      1 Reply Last reply
      1
      • T TauCeti

        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?

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

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

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1
        • T Offline
          T Offline
          TauCeti
          wrote on last edited by
          #4

          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.

          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