Results 1 to 3 of 3

Thread: Delete Windows shortcut file

  1. #1
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    229
    Thanks
    2
    Thanked 29 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Delete Windows shortcut file

    Hello,

    in my application I search for files and the user can select from the found files and delete them.
    Now I have the problem that if a file is a Windows shortcut QFile::remove(...) cannot remove the shortcut as it tries to remove the linked file.

    E.g.
    - C:\theShortcut.html.lnk points to C:\path\someFile.html
    - Now I want to delete the shortcut with QFile::remove("C:\theShortcut.html.lnk")
    - But now Qt tries to delete C:\path\someFile.html (let us ignore whether the file exists or not)

    Is there a way to delete a Windows shortcut file with Qt?

  2. #2
    Join Date
    May 2011
    Posts
    239
    Thanks
    4
    Thanked 35 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Symbian S60

    Default Re: Delete Windows shortcut file

    I guess this is a Qt bug and there is no workaround in Qt. You may need to resort to a C++ runtime function (unlink(), remove()) or a Windows API function to do the deletion.

  3. #3
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Delete Windows shortcut file

    or get boost filesystem which will work on win and *nix.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar Threads

  1. delete file with qt
    By dpn in forum Qt Programming
    Replies: 2
    Last Post: 10th January 2013, 15:21
  2. Replies: 2
    Last Post: 26th March 2012, 23:38
  3. how to delete a file
    By athulms in forum Newbie
    Replies: 2
    Last Post: 13th October 2011, 02:19
  4. How to delete File
    By rajesh in forum Qt Programming
    Replies: 1
    Last Post: 7th November 2006, 12:23
  5. delete sub windows when they are closed?
    By Dark_Tower in forum Newbie
    Replies: 3
    Last Post: 21st March 2006, 19:50

Tags for this Thread

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.