PDA

View Full Version : QFileDialog Question



ToddAtWSU
21st August 2019, 20:29
I have an application running on RHEL 7.3 and in this application the user opens an XML file. They can either pass in this file as a command line argument or through a File Dialog. I use the static function QFileDialog::getOpenFileName() but noticed in the Qt docs it says for Windows and MAC, it uses a native dialog. But in Linux it appears it uses a QtDialog. Is there a way to make the application use the RHEL specific file choosing dialog. The directory it needs to open to has approximately 4000 files in it and the dialog is a bit slow (upwards of a minute) for selecting a file. I thought maybe using a native dialog to RHEL would help speed this up? Has anybody experienced this issue before? These machines have 8 GB or 16 GB of RAM in them. It might be there is no way to make this faster, just thought I would ask other people before telling them they have to deal with the slowness until they clean up their directory.

Thanks!

d_stranz
22nd August 2019, 18:26
The QFileDialog docs say that the native dialog will be used when there is one. (See QFileDialog::DontUseNativeDialog). Maybe the style you are using for the app doesn't have a conforming native dialog. Check the styles available for RHEL in your Qt distribution and maybe there is an alternative.

Try changing the Options flag for getOpenFilename() to set the DontUseNativeDialog bit and see if you get the same thing.

There is some mention in the RHEL 7.3 release notes (https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/7.3_release_notes/new_features_desktop) about Qt style changes.

anda_skoa
24th August 2019, 09:54
The QFileDialog docs say that the native dialog will be used when there is one. (See QFileDialog::DontUseNativeDialog). Maybe the style you are using for the app doesn't have a conforming native dialog. Check the styles available for RHEL in your Qt distribution and maybe there is an alternative.


More precisely this is part of the platform integration part of Qt, the the platform theme plugin.

For example on a KDE Plasma Desktop you will get the KDE File Dialog if the Qt version of the application matches the Qt version of the desktop but you'll get the built-in Qt dialog if there is a version mismatch.

So it also depends a bit on whether the application uses its own Qt or the system Qt.

Cheers,
_

ToddAtWSU
26th August 2019, 19:29
Okay, so this is starting to make some sense. We are forced to use Gnome and when I run some applications, I get an error: GTK-Message: GTKDialog mapped without a transient parent. This is discouraged.

So maybe it is trying to use the GTKDialog for the QFileDialog, and I get this error as it doesn't know how to use a QMainWindow for its parent. And then maybe if I don't use the native dialog like you suggest, it will work. I wasn't certain if I was using the native dialog because the documentation wasn't clear in Linux:


On Windows, and macOS, this static function will use the native file dialog and not a QFileDialog.

It never mentioned Linux so I assumed it was using the QFileDialog, but I think it is now using the GTKDialog so I will try disabling this and see what happens. Thanks for your help

anda_skoa
27th August 2019, 10:12
get an error: GTK-Message: GTKDialog mapped without a transient parent. This is discouraged.

This is probably just a warning, not an error.

As far as I understand the "transient parent" is the window which the dialog should be placed on top of, otherwise the dialog could theoretically be move "below" the parent.
It should still work though.



So maybe it is trying to use the GTKDialog for the QFileDialog, and I get this error as it doesn't know how to use a QMainWindow for its parent.

This kind of window relationship is handled on the level of window system handles, e.g. X11 window IDs, so this shouldn't be a problem.

But of course there could be limitation on the integration API and/or bugs.

Cheers,
_