Results 1 to 7 of 7

Thread: QFile::remove() strange refresh problem in windows desktop

  1. #1
    Join Date
    Jul 2007
    Posts
    35
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question QFile::remove() strange refresh problem in windows desktop

    Hi all,
    I'm working on windows 7 with qt 4.6.
    I'm doing batch operations on file and then deleting files. I'm using QFile::remove() for deleting each file.
    For files which user desktop when deleting files ,files were deleted but in windows explorer files are still on desktop. When i refresh(F5) user desktop files are disappeared.

    But for files which in folder this is not occured and all files deleted immediately.

    Is there any way to solve this problem or refresh user desktop with code ?

    Thanks in advance

    Ramazan Girgin

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QFile::remove() strange refresh problem in windows desktop

    Is that of concern to the program deleting the files?
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  3. #3
    Join Date
    Sep 2010
    Posts
    145
    Thanks
    1
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QFile::remove() strange refresh problem in windows desktop

    See SHGetSpecialFolderLocation, SHChangeNotify. You have the pieces to form a solution now.

    The reason why this happens is that QFile::remove() is implemented with DeleteFile() in Windows. DeleteFile() is what is used to implement the crt itself, and does not post any notification to the shell.

  4. #4
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QFile::remove() strange refresh problem in windows desktop

    This problem occurs with many other applications, not only Qt. Bad Windows constructions.

  5. #5
    Join Date
    Sep 2010
    Posts
    145
    Thanks
    1
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QFile::remove() strange refresh problem in windows desktop

    No, it is not the fault of Windows in this case. Windows provides an api subset for interaction with "special folders" (such as the desktop) which is Shell API. I'm assuming that Trolltech chose not to use the Shell API because DeleteFile() is basically guaranteed to exist because of the c runtime's dependency on it (as well as other legacy api code) and the Shell API suffers a break between XP and Windows 7 with file operations. Interacting with a folder that has special significance to the shell without using the shell api is what is bad. So, if you don't like the behavior, it is time to bust out some winapi.

  6. #6
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QFile::remove() strange refresh problem in windows desktop

    TBH, since you can register file/dir notifications with the shell, I kinda expected the shell to use that itself so that when someone modifies a folder, regardless of where it is, it refreshes the open windows that are showing that directory.

    Every app can see special directories like "Desktop", but I don't think any of the applications I have treat it any differently than any other dir.

  7. #7
    Join Date
    Sep 2010
    Posts
    145
    Thanks
    1
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QFile::remove() strange refresh problem in windows desktop

    You mean you can register your app to receive file notifications from the shell, right? The context of "someone" is very important. If "someone" is the typical user, then they used the shell to make the modifications so the shell already knows about it. If "someone" is a program written with the standard library for file IO, then the shell will know when it is asked to check. If "someone" is a program written against the shell api, then the shell will know just as if the user himself had done it.
    but I don't think any of the applications I have treat it any differently than any other dir.
    It comes down to whether or not it is suitable for the shell to wait until it is asked by the user (or another process) to refresh the desktop. Also it is worth mentioning that for most purposes the shell api is overkill for file operations.

Similar Threads

  1. Replies: 7
    Last Post: 13th February 2014, 06:23
  2. Accessing GPS device from qt desktop(windows) App
    By newtolinux in forum Qt Programming
    Replies: 7
    Last Post: 2nd November 2010, 20:05
  3. Replies: 2
    Last Post: 6th September 2010, 14:22
  4. Associate Program Icon for Windows Desktop
    By brent99 in forum Newbie
    Replies: 2
    Last Post: 11th March 2008, 04:22
  5. Draging a non-existing file to the Windows Desktop
    By klaus1111 in forum Qt Programming
    Replies: 13
    Last Post: 20th September 2007, 11:47

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.