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. [Solved] Qt5 - QFileDialog shows only directories
Forum Updated to NodeBB v4.3 + New Features

[Solved] Qt5 - QFileDialog shows only directories

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.0k 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.
  • B Offline
    B Offline
    Banshee
    wrote on last edited by
    #1

    Hello,
    Since I use Qt5 (and not Qt4.8), my QFileDialog shows only directories and no files anymore.

    @
    [...]
    QString path;
    QFileDialog dialog(this);
    dialog.setFileMode(QFileDialog::Directory);
    dialog.setViewMode(QFileDialog::Detail);
    dialog.setDirectory(temp);
    if (dialog.exec())
    path = dialog.selectedFiles().isEmpty() ? QString() : dialog.selectedFiles()[0];
    if (!path.isEmpty()){
    ui->groupBox_type->setVisible(true);
    ui->button_more->setVisible(true);
    ui->lineEditSource->setText(path);
    }
    [...]
    @

    In addition, the QFileDialog doesn't use the stylesheet of its parent, but the native Windows-Style. It seems like Qt5 now uses the native "select directory"-dialog for the options above.
    But there is no change in the "documentation":https://qt-project.org/doc/qt-5.0/qtwidgets/qfiledialog.html#FileMode-enum, so how can I get that behaviour to be as it was in Qt4?
    I use Qt5.2.0-msvc2010-opengl on Win7.

    Thank you all :)

    [EDIT: Ok, I found the problem:
    Since Qt5, you need setOption(QFileDialog::DontUseNativeDialog) to disable the native dialog.
    I think it is a bit confusing that setFileMode(QFileDialog::Directory) doesn't show files on WIndows even if its mentioned to do it in the documentation, but well.]

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      AFAIK, Qt 4 also used native dialogs by default.

      Then indeed, there's no styling propagated since the dialog comes directly from the OS (in your case windows) So are you saying the between Qt 4 and Qt 5 the native dialog doesn't do the same things ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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