View Full Version : Bypass MessageBox QFileSystemModel

7th June 2014, 23:24
Hi all,
Is it possible to bypass the QMessageBox that QFileSystemModel do when a rename can not be done ?
The probleme is the message is not good because the message is always the same, if a file has same name he doesn't say it.
The real problem is not really the message but it's impossible to know if rename failed.
I would log an error message when the rename failed.
Thanks for the help

8th June 2014, 04:38
The "Invalid filename" message box tells you the file name that is a problem.

If you just want to rename a file why not use QDir::rename() directly and check the return value? You could even check if the target file name exists before you try to rename to it.

8th June 2014, 17:55
I don't do anything, the QFileSystemModel does this message box by himself, that's why my question.
I just have the model no read-only to allow edit, and this message is managed by the model.

8th June 2014, 23:47
Which is why ChrisW67 suggested doing the renaming in code you control.

For example with a custom delegate to handle the editing differently, or a model derived from QFileSystemModel and a setData() override that handles it differently or a proxy model inbetween the unchanged model and the view with a setData() that handles the rename.