Page 1 of 1

QFileDialogAppearance on Linux

Posted: Wed Sep 30 2020 9:51 pm
by seasoned_geek

I tested this out on Fedora (current) and Ubuntu 20.04. This is what QFileDailog looks like.

According to the doc it should be providing the "system file dialog" (or wording something like that). On Ubuntu the system file dialog looks like this:

It didn't matter if I set this option true/false, I always got the same dialog as the image in the first link. No ability to navigate to network drives or enable the viewing of hidden files.

I created a Qt test app using whatever was on that Ubuntu 20.04 machine. The zip of which should download from this link

I didn't fully flesh this out, just got enough to launch each dialog.

Code: Select all

#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <QFileDialog>
#include <QStringList>
#include <QDir>
#include <QDebug>
#include <QProcess>
#include <QByteArray>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)

    connect(ui->actionOpen, &QAction::triggered, this, &MainWindow::fileDialogOpen);
    connect(ui->actionOpen_File, &QAction::triggered, this, &MainWindow::zenityOpen);

    delete ui;

void MainWindow::fileDialogOpen()
    QStringList lst = QFileDialog::getOpenFileNames(this, "Choose file", QDir::homePath());

    qDebug() << "files: " << lst;

void MainWindow::zenityOpen()
    // yes I cheated hard coding the path
    QString cmd = QString("/usr/bin/zenity --file-selection --title=\"Select a File\" --multiple");

    QProcess *myProcess = new QProcess(this);

    qDebug() << "Zenity command: " << cmd;

    QByteArray a = myProcess->readAllStandardOutput();

    qDebug() << "Zenity returned: " << a << "  ExitStatus: " << myProcess->exitStatus();

QFileDialog using Qt 5.x default on Ubuntu 20.04

Zenity on Ubuntu 20.04

Zenity test Qt 5

Zenity navigate to other

Choose SortPairs.cpp

This came back

As one can see from the screenshots it looks like QFileDialog in Qt 5.x is using Zenity on Ubuntu default desktop. I didn't spin up a system with Qt 4.8 to see if I've just been working with Qt 5.x too long. I also didn't spin up a KDE system to see if they are using KDialog on it or if Zenity exists on most. Zenity does exist on my Fedora system, but it is Gnome based so that is not a shock.

Does QFileDialog have some outstanding issues on Linux in CopperSpice? [edited]