Opening directory in classic snap gives wrong path

I created a classic snap for an IDE to get access to the entire filesystem, build tools, libraries, headers. When opening a project directory via the UI, I get a “Choose Directory” dialog that lets me navigate my home folder to the project directory (e.g. /home/christian/projects/my_new_project):

But when I acknowledge the path with “Select”, the resulting path will be /run/user/1000/doc/ed19bf8b/. This is a bit confusing because all paths to source files are different now from the host. Also, the build system behaves differently in this path than in the original host path (it breaks because it cannot create lock files).

I can work around this by just entering the host path manually instead of using the directory-selection-dialog. But this will not always be possible.

How do I tell snapcraft to not use any sandboxing but behave as it would run on the host?

try to set GTK_USE_PORTAL to 0 in the environment of the app, seems your app uses the xdg portal which you do not want to be used in classic snaps …

I added this to the app's environment but I get the same result.

I noticed that my “Choose Directory” dialog (I added a screenshot to the original issue) is different from the “Open Folder” dialog that the Visual Studio Code snap uses.

The “Choose Directory” comes from a custom class Utils::PathChooser in Qt Creator. This in turn uses FileUtils::getExistingDirectory and QFileDialog::getExistingDirectory.

Is QFileDialog::getExistingDirectory expected to behave like the other file dialogs in snaps? I am building Qt 6 from scratch in my snap. So do I maybe have to pass some specific CMake arguments to make this happen?