Skip to content

Retrieve the true file path using QFileDialog #72

@tdard

Description

@tdard

Hi,

I try to get the path to an existing file, but the resulting path has a weird prefix, like it is moved in a temporary directory:
for a file located at /home/<user_name>/<folder_name>/<file_name.extension> I obtain the following path:
/run/user/1000/doc/daf242de/<file_name.extension>

Here is the sample code (tested on Ubuntu)

if __name__ == "__main__":
    from PyQt5.QtWidgets import QApplication, QFileDialog

    app = QApplication([])

    dialog = QFileDialog()
    dialog.setFileMode(QFileDialog.ExistingFile)  # Accept a single file that exists
    if dialog.exec():
        file_path = dialog.selectedFiles[0]
        print(file_path)

Do you know if it is normal, and how I could I configure the dialog such that I could retrieve the true path of the file I'm searching for?
Kind regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions