Results 1 to 5 of 5

Thread: Force Delete a file or folder in Qt

  1. #1
    Join Date
    Jul 2015
    Posts
    16
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Question Force Delete a file or folder in Qt

    Hi , How to force delete a file or folder using Qt ??
    With administrator permissions ...

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Force Delete a file or folder in Qt

    You can delete files and directories with a combination of QFile::remove(), QDir::remove() and QDir::rmdir().

    If you require Windows to elevate privileges then you must use the Windows APIs to achieve that.
    http://stackoverflow.com/questions/2...indows-api-c-c

  3. #3
    Join Date
    Jul 2015
    Posts
    16
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Force Delete a file or folder in Qt

    Quote Originally Posted by ChrisW67 View Post
    You can delete files and directories with a combination of QFile::remove(), QDir::remove() and QDir::rmdir().

    If you require Windows to elevate privileges then you must use the Windows APIs to achieve that.
    http://stackoverflow.com/questions/2...indows-api-c-c
    Not a better way ?? With a built-in function or class or struct ???

  4. #4
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Force Delete a file or folder in Qt

    AFAIK, no. There is no object in Qt which would pop up a "password" dialog and (if answered correctly) give you root priviledges. Because some apps can do that, there should be a way of writing such object yourself. The object will depend on the operating system (windows, Linus, etc.)

    -------------------

    [Edit] ChrisW67s link contains a way of doing it under windows.
    Last edited by Radek; 22nd July 2015 at 17:16.

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Force Delete a file or folder in Qt

    The necessary mechansims/functions are builtin in to every copy of Windows since Vista, they are fully documented, widely used, utterly non-portable, and frankly ugly. They are, nonetheless, the better way because the alternative is that Windows stayed the wide-open malware magnet its original design made it.

Similar Threads

  1. How to force include a header file
    By rawfool in forum Newbie
    Replies: 25
    Last Post: 13th December 2015, 23:34
  2. Qt 5.1 : Want to put qt.conf file in different folder that application exe folder
    By Rajesh.Rathod in forum Installation and Deployment
    Replies: 1
    Last Post: 20th July 2014, 14:48
  3. Replies: 7
    Last Post: 3rd February 2014, 14:27
  4. How to delete a folder in Qt Creator Project View?
    By stephenzhu in forum Qt Programming
    Replies: 2
    Last Post: 23rd March 2012, 16:26
  5. Qt deleteLater() force to delete
    By axe in forum Qt Programming
    Replies: 28
    Last Post: 19th August 2011, 12:04

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
  •  
Qt is a trademark of The Qt Company.