Disable "Open" button when no file is selected in QFileDialog
-
Hi,
We are making an internal configuration tool using PyQt5 5.15.4.
Development is done on macOS Catalina 10.15.7
The final version will run on both OSX and Windows 10On Windows 10, when you open a QFileDialog, the "Open" button is enabled even when no file is selected.
Here is an image to illustrate the issue.Is there a way to change this behaviour?
For example, on MacOS, the button is disabled as long as no file is selected.
Would it be possible to have the same behaviour on Windows 10?Thanks,
FVez -
Hi,
How are you invoking that dialog ?
-
Hi,
We are making an internal configuration tool using PyQt5 5.15.4.
Development is done on macOS Catalina 10.15.7
The final version will run on both OSX and Windows 10On Windows 10, when you open a QFileDialog, the "Open" button is enabled even when no file is selected.
Here is an image to illustrate the issue.Is there a way to change this behaviour?
For example, on MacOS, the button is disabled as long as no file is selected.
Would it be possible to have the same behaviour on Windows 10?Thanks,
FVez@fvez_demtroys
Are you aware that this is actually the normal behaviour of this Windows "Open" dialog, e.g. cf. from Notepad? I had never noticed and agree I don't know why, but given it's the standard Windows behaviour do you really want to bother to try changing it? -
@SGaist I invoke the dialog with
QFileDialog.getOpenFileName(caption='Open .txt', filter="Text Files (*.txt)")@JonB Yes I did see that this seemed like standard behaviour on Windows.
I was wondering if QFileDialog had a way of disabling the open button as long as no file is selected.
I don't necessarily want to change it manually, seems like a lot of work for very little gain.
I added safety checks on the string obtained by getOpenFileName, this way if no file is selected it shouldn't cause issues.Thanks!
FVez -
@SGaist I invoke the dialog with
QFileDialog.getOpenFileName(caption='Open .txt', filter="Text Files (*.txt)")@JonB Yes I did see that this seemed like standard behaviour on Windows.
I was wondering if QFileDialog had a way of disabling the open button as long as no file is selected.
I don't necessarily want to change it manually, seems like a lot of work for very little gain.
I added safety checks on the string obtained by getOpenFileName, this way if no file is selected it shouldn't cause issues.Thanks!
FVez@fvez_demtroys said in Disable "Open" button when no file is selected in QFileDialog:
I was wondering if QFileDialog had a way of disabling the open button as long as no file is selected.
I'm not sure, but I don't think so. You are using the native Windows dialog here, not the Qt-rolled alternative one. That means it looks and functions under the windowing system's control, I believe.