Access native QFileDialog

905 views Asked by At

I'm writing a ui test for a Qt application. Now this application raises a QFileDialog which must be automatically filled in and committed.

I already have a QTimer which runs even when the modal dialog is shown. This approach works for many dialogs e.g. QMessageBox or QColorDialog.

The Problem is, that the QFileDialog is a native dialog. So I can't search for the dialog widget, because there is none.

Is there a way to access the native dialog.

I'm developing on Ubuntu so I guess it's a GTK dialog. The tests will always run on Ubuntu.

1

There are 1 answers

2
acj On

Depending on your needs you could just set QFileDialog::DontUseNativeDialog to true using void QFileDialog::setOption(Option option, bool on = true) before you show the dialog. Then you should have a widget to search for.

See: http://doc.qt.io/qt-5/qfiledialog.html#setOption