QFileDialog not responding to done() method as QDialog does
-
@MrAWD
I can't test on Windows, but on Mac and Linux, a warning dialog pops up if the file name your enter already exist.
It's not like that on Windows ?For your "done" issue, have a try with a non native file dialog :
setOption(QFileDialog::DontUseNativeDialog)wrote on 7 Dec 2022, 21:59 last edited by@mpergand said in QFileDialog not responding to done() method as QDialog does:
@MrAWD
I can't test on Windows, but on Mac and Linux, a warning dialog pops up if the file name your enter already exist.
It's not like that on Windows ?For your "done" issue, have a try with a non native file dialog :
setOption(QFileDialog::DontUseNativeDialog)Actually, I just tried it and it one works as it should and doesn't close the dialog due to code in done() method when "Save" button is clicked.
It looks like this has something to do with that native Windows "Save As" dialog that is ignoring what overridden done() is doing -
wrote on 8 Dec 2022, 01:54 last edited by MrAWD 12 Aug 2022, 01:56
I have been trying to make things to work without using native dialog, but performances of this other dialog are really bad. It takes more than a second to load the content of the directory to the list (even though only two files were there) and that is a big turn off. It is also ugly as hell! :)
I will have to figure out how to use native dialog here, since this one is not going to cut it. If you have any other ideas on what to do here, I would appreciate it.
-
wrote on 8 Dec 2022, 08:41 last edited by
Kind of a stab in the dark here, but what I remember about dialogs was taht they can be modal or non-modal, thus having different implications of how to submit their data. QFileDialog is probably modal by default, but QDialog may not be. Something in the far reaches of my memory hints at this being relevant.
-
I have been trying to make things to work without using native dialog, but performances of this other dialog are really bad. It takes more than a second to load the content of the directory to the list (even though only two files were there) and that is a big turn off. It is also ugly as hell! :)
I will have to figure out how to use native dialog here, since this one is not going to cut it. If you have any other ideas on what to do here, I would appreciate it.
wrote on 8 Dec 2022, 13:37 last edited by@MrAWD
I said I would get back to you once tested. I can only say that under Linux (Qt5.15.x, PySide2) the code does behave as you want it to, in particular the "Save" dialog does stay visible after "accepting". And it does so with either the native or Qt file dialogs. So your behaviour must be a Windows native dialog issue? -
@MrAWD
I said I would get back to you once tested. I can only say that under Linux (Qt5.15.x, PySide2) the code does behave as you want it to, in particular the "Save" dialog does stay visible after "accepting". And it does so with either the native or Qt file dialogs. So your behaviour must be a Windows native dialog issue?wrote on 8 Dec 2022, 13:48 last edited by@JonB said in QFileDialog not responding to done() method as QDialog does:
@MrAWD
I said I would get back to you once tested. I can only say that under Linux (Qt5.15.x, PySide2) the code does behave as you want it to, in particular the "Save" dialog does stay visible after "accepting". And it does so with either the native or Qt file dialogs. So your behaviour must be a Windows native dialog issue?Jon, thanks for testing this and confirming that Linux side works as expected.
Now, what to do about that Windows one that is my primary platform here?
-
The thing is: one Windows and macOS, it's the native dialog that is used however there's no such thing on Linux.
Try to force the use of non-native file dialog and see if it does what you want. -
The thing is: one Windows and macOS, it's the native dialog that is used however there's no such thing on Linux.
Try to force the use of non-native file dialog and see if it does what you want.wrote on 8 Dec 2022, 14:14 last edited by JonB 12 Aug 2022, 14:16@SGaist said in QFileDialog not responding to done() method as QDialog does:
The thing is: one Windows and macOS, it's the native dialog that is used however there's no such thing on Linux.
?? Dialog is quite different under Ubuntu (GNOME) with vs without
DontUseNativeDialog
! It most certainly does have a native dialog :) I think Linux/Ubuntu may lack a directory selector native dialog, but that's quite different/not this case. -
Might be related to Gnome using GTK.
-
wrote 28 days ago last edited by
I know the post is quite old, but I'm also facing the issue on windows, using PyQt5.
Did you find a way to prempt the closure of the native windows filedialog ? -
I know the post is quite old, but I'm also facing the issue on windows, using PyQt5.
Did you find a way to prempt the closure of the native windows filedialog ?wrote 27 days ago last edited by@Kaostheory said in QFileDialog not responding to done() method as QDialog does:
I know the post is quite old, but I'm also facing the issue on windows, using PyQt5.
Did you find a way to prempt the closure of the native windows filedialog ?The way I made it work for me was to use non native dialog...nothing else worked back in days. Since those days, I am using pySide6 now (no more pySide2 here) and I didn't retest original behavior - now thinking I should have!
The same goes for you with PyQt5 and test with PyQt6 might be an option to try.
If I get around to test this again with pySide6, I will update this thread. Good luck!