Is there a Qt function to move files to Recycle Bin instead of truly deleting them, for OSes that support it, or do I need to use OS-specific code?
If you delete a file with a size bigger than the Recycle Bin limit, it won't go into the bin. On your desktop, right-click the Recycle Bin icon and then click Properties. When the Recycle Bin dialog box pops up, ensure that the radio button under Settings for selected location is on Custom size.
Whenever you delete a file in your computer and empty your Recycle Bin, your data is not entirely wiped out from your computer. Although you can no longer see the file on the location it once was and your operating system no longer has it, a copy of it still exists in your hard drive.
Since Qt 5.15.0 Alpha, this method has been added, which should be what you were looking for.
bool QFile::moveToTrash()
The corresponding code changes can be found here.
(This issue is old and the corresponding Bugreport at https://bugreports.qt.io/browse/QTBUG-47703 has already been posted, but I currently lack the reputation to comment, and found this to be a useful information.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With