Clear File Selection in a QFileDialog
-
How do you clear which files are selected in a QFileDialog?
-
Hi
What do you mean by clear?
The user selects files. or deselects them. -
I want to be able to programmatically deselect all highlighted files.
-
@DougyDrumz
While the dialog is open? -
I've created a custom file dialog. I make one instance of it in my code. When I open that dialog I select a file name. When I open it again, the same file name is selected. I don't want it to be selected when I open it the second or succeeding time.
-
@DougyDrumz said:
Ahh. a QFileDialog, yes?
Have you tried to clear
QStringList QFileDialog::selectedFiles()
or
yourdialog.selectFile( ""); -
I had tried yourdialog.selectFile( "");, but that didn't seem to work. I'll try to clear selectedFiles().
-
@DougyDrumz
ok. else if its completely stupid then maybe just new it each time and use
setAttribute( Qt::WA_DeleteOnClose );
to clean up?As if you create new instance, its should be impossible for it to remember. :)
-
Yeah. I thought about that too. Maybe I'm over-thinking this.
-
@DougyDrumz
Well, one wonder where it remembers it.
Maybe its just the list itself.
so selectFile( ""); dont work as not select new and
selectedFiles is already empty.
so yeah, kill it ;) -
Thanks! That did the trick. However, I had to delete each instance by hand, instead if using Qt::WA_DeleteOnClose, because I was referencing data from the dialog after it was closed.