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 on different platforms
Forum Updated to NodeBB v4.3 + New Features

QFileDialog on different platforms

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 25 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.
  • P Offline
    P Offline
    PaWa
    wrote last edited by PaWa
    #1

    Hi Forum
    Asking some help here doing some multiplatform work. I have a pretty simple and straight forward open method opening some files. It works great and compiles on all platforms. On macOS (both Intel/Silicon) the filter for the filename suffix makes the filtered out files "grayed out" than than not showing them.
    Is there a way around this? I do not like sifting through grayed-out files when I applied a filer to show only, for example, .pro-files. Works perfectly on Windows (PC), Linux (PC), Raspberry PI, Haiku/BeOS (PC) but not on macOS (Intel/Apple Silicon). Any suggestions or is it something I have to live with a MacOS?

    QT 6.9.1 on PC, QT 5 somthing on Raspberry, QT 6.91 on both Mac

    void MceBaseEditor::openFile()
    {
    QString startDir = getUserHomePath();
    if (!lastOpenFilePath.isEmpty()) {
    QFileInfo info(lastOpenFilePath);
    if (info.exists() && info.isDir()) {
    startDir = lastOpenFilePath;
    }
    }

    QString fileName = QFileDialog::getOpenFileName(
        this,
        "Open File",
        startDir,
        "C/C++/CS Files (*.c *.cpp *.cc *.cxx *.cs *.h *.hpp *.hh *.hxx);;"
        "Pascal Files (*.pas *.pp);;"
        "Python Files (*.py);;"
        "Ada Files (*.ada *.adb *.ads);;"
        "Qt Project Files (*.pro);;"
        "Text and Markup Files (*.txt *.json *.xml *.md);;"
        "All Files (*.*)"
    );
    
    if (!fileName.isEmpty()) {
        openFile(fileName);
    }
    updateFileActions();
    

    }

    Regards /Patrik

    1 Reply Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote last edited by
      #2

      I believe is is because by default the file open dialog uses the "OS native" file dialog of the system on which is running. I'm not a MAC person but is that the default MAC behaviour? I also thought there was a way to disable (a switch) to tell the framework to not use the native OS dialogs, but I haven't messed with that stuff in ages so I cannot tell you quickly what it was, or even if I was hallucinating.

      I light my way forward with the fires of all the bridges I've burned behind me.

      B 1 Reply Last reply
      0
      • Kent-DorfmanK Kent-Dorfman

        I believe is is because by default the file open dialog uses the "OS native" file dialog of the system on which is running. I'm not a MAC person but is that the default MAC behaviour? I also thought there was a way to disable (a switch) to tell the framework to not use the native OS dialogs, but I haven't messed with that stuff in ages so I cannot tell you quickly what it was, or even if I was hallucinating.

        B Offline
        B Offline
        Bonnie
        wrote last edited by Bonnie
        #3

        @Kent-Dorfman said in QFileDialog on different platforms:

        I also thought there was a way to disable (a switch) to tell the framework to not use the native OS dialogs, but I haven't messed with that stuff in ages so I cannot tell you quickly what it was, or even if I was hallucinating.

        Yes, there is QFileDialog::DontUseNativeDialog in QFileDialog::Options, or the global Qt::AA_DontUseNativeDialogs application attribute.
        But OP must be noted that this uses Qt's own ui and looks far way different from the native file dialogs.

        Also from the doc of Qt5 there's a note above this option, not sure what it means as I don't have a MAC system

        Note: This option is not supported on macOS when using the native file dialog.

        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