Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QFileDialog with strange behavior
Forum Updated to NodeBB v4.3 + New Features

QFileDialog with strange behavior

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 319 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    Quorn Julio
    wrote on last edited by Quorn Julio
    #1

    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.
    screenshot.png

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

    I am grateful for any help.

    MacOS 12.1 - Qt 6.2.2

    Pl45m4P 1 Reply Last reply
    0
    • Q Quorn Julio

      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.
      screenshot.png

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

      I am grateful for any help.

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by Pl45m4
      #2

      @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->fileDialog->setWindowModality(Qt::WindowModal);
      this->fileDialog->setModal(true);

      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

      EDIT:

      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 with setModal(true) is not recommended on MacOS.
      If this causes your jump?! I don't know :)


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      Q 1 Reply Last reply
      2
      • Pl45m4P Pl45m4

        @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->fileDialog->setWindowModality(Qt::WindowModal);
        this->fileDialog->setModal(true);

        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

        EDIT:

        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 with setModal(true) is not recommended on MacOS.
        If this causes your jump?! I don't know :)

        Q Offline
        Q Offline
        Quorn Julio
        wrote on last edited by
        #3

        @Pl45m4

        Thank you so much!

        QDialog::open()
        

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

        MacOS 12.1 - Qt 6.2.2

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved