Solved 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()); this->fileDialog->setWindowFlags(Qt::Sheet); this->fileDialog->setWindowModality(Qt::WindowModal); this->fileDialog->setModal(true); ... this->fileDialog->exec()
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()
withthis
or some other valid parent and try if your dialog "jumps" again@Quorn-Julio said in QFileDialog with strange behavior:
this->fileDialog->setWindowModality(Qt::WindowModal);
this->fileDialog->setModal(true);This is redundant... first line sets
fileDialog
window toWindowModal
, the second overrides this setting withApplicationModal
, which is pretty much the same in a parent-child-hierarchyEDIT:
And there is also this:
Qt::Sheet
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 withsetModal(true)
is not recommended on MacOS.
If this causes your jump?! I don't know :) -
Thank you so much!
QDialog::open()
works properly / as expected. i wonder why
QDialog::exec
does not!
I would have expected the same behavior.