Qt World Summit: Submit your Presentation

QFileDialog with strange behavior

  • Hello,

    first of all i develop under mac 10.14.6 (Mojave) using Qt 5.15.0.
    in my program i use QFileDialog as follow:

    this->fileDialog = new QFileDialog(window());

    The strange thing is here that the dialog opens on the right position but than jumps down with a certain offset Y.

    I try to "fix" the position of QFileDialog with setGeometry(0, 0, 500, 400) but this without success.

    I am grateful for any help.

  • @Quorn-Julio said in QFileDialog with strange behavior:

    this->fileDialog = new QFileDialog(window());

    This looks weird... Replace window() with this or some other valid parent and try if your dialog "jumps" again

    @Quorn-Julio said in QFileDialog with strange behavior:


    This is redundant... first line sets fileDialog window to WindowModal, the second overrides this setting with ApplicationModal, which is pretty much the same in a parent-child-hierarchy


    And there is also this:


    Indicates that the window is a sheet on macOS. Since using a sheet implies window modality, the recommended way is to use QWidget::setWindowModality(), or QDialog::open(), instead.
    (From: https://doc.qt.io/qt-5/qt.html#WindowType-enum)

    So I guess, using Qt::Sheet together with setModal(true) is not recommended on MacOS.
    If this causes your jump?! I don't know :)

  • @Pl45m4

    Thank you so much!


    works properly / as expected. i wonder why QDialog::exec does not!
    I would have expected the same behavior.

Log in to reply