Skip to content

QFileDialog fails to use platform-native dialog if static linked #33

Open

Description

@hebasto

While investigating #32 I found a buggy (?) behavior of QFileDialog.

From the Qt docs:

By default, a platform-native file dialog will be used if the platform has one.

When Qt and QPA plugin are dynamic linked:

$ ./src/qt/bitcoin-qt -printtoconsole
2020-07-15T09:15:39Z [main] Bitcoin Core version v0.20.0 (release build)
2020-07-15T09:15:39Z [main] Qt 5.12.8 (dynamic), plugin=xcb (dynamic)

QFileDialog works as expected, and uses a platform-native file dialog.


When Qt and QPA plugin are static linked (gitian builds):

$ /home/hebasto/bitcoin-0.20.0/bin/bitcoin-qt -printtoconsole
2020-07-15T09:07:04Z Bitcoin Core version v0.20.0 (release build)
2020-07-15T09:07:04Z Qt 5.9.8 (static), plugin=xcb (static)

QFileDialog fails to recognize the platform, and uses a widget-based implementation.

Even running with QT_QPA_PLATFORM=xcb doesn't help.

Activity

  1. added
    Bug
    on Jul 15, 2020
  2. hebasto commented on Jul 15, 2020

    @hebasto
    MemberAuthor

    https://forum.kde.org/viewtopic.php?t=90626#p172050:

    In order to use the native KDE file dialog, you need to link to Qt dynamically.

    https://forum.kde.org/viewtopic.php?t=90626#p172100:

    This is a limitation in Qt, not KDE.
    Qt cannot guarantee that plugin loading works on all platforms when being linked statically.

    Especially not when the plugin is linked against a different version of Qt.

    Could be related:

  3. maflcko commented on Jul 15, 2020

    @maflcko
    Contributor

    So why is the widget based dialog unable to detect any folders?

  4. hebasto commented on Jul 15, 2020

    @hebasto
    MemberAuthor

    So why is the widget based dialog unable to detect any folders?

    That is the question in #32, and I'm still working on it :)

    This issue differs from #32.

  5. ryanofsky commented on Jul 15, 2020

    @ryanofsky
    Contributor

    Nice find!

  6. hebasto commented on Jul 16, 2020

    @hebasto
    MemberAuthor

    @MarcoFalke

    So why is the widget based dialog unable to detect any folders?

    A: bitcoin/bitcoin#19536

  7. hebasto commented on Aug 9, 2020

    @hebasto
    MemberAuthor

    UPDATE: such behavior observed on Linux only.

    Static builds work fine on Windows (tested Windows 10) and macOS (tested macOS 10.15.6).

  8. fanquake commented on Aug 10, 2020

    @fanquake
    Member

    UPDATE: such behavior observed on Linux only.

    I thought this was fixed by bitcoin/bitcoin#19536?

    This change partially reverts 248e22b (#16386) and makes QFileDialogs work again for static builds.
    Fixes #32.

    Right, I see these are separate.

  9. hebasto commented on Aug 10, 2020

    @hebasto
    MemberAuthor
    $ make -C depends
    make: Entering directory '/home/hebasto/guix/GitHub/bitcoin/depends'
    Extracting qt...
    /home/hebasto/guix/GitHub/bitcoin/depends/sources/qtbase-opensource-src-5.9.8.tar.xz: OK
    /home/hebasto/guix/GitHub/bitcoin/depends/sources/qttranslations-opensource-src-5.9.8.tar.xz: OK
    /home/hebasto/guix/GitHub/bitcoin/depends/sources/qttools-opensource-src-5.9.8.tar.xz: OK
    Preprocessing qt...
    ...
    Configuring qt...
    Creating qmake...
    ...
    Done running configuration tests.
    
    Configure summary:
    ...
    Qt Widgets:
      GTK+ ................................... no
      Styles ................................. Fusion Windows
    ...
    

    @theuni
    Could missed GTK+ support cause this bug?

  10. hebasto commented on Aug 11, 2020

    @hebasto
    MemberAuthor

    This @laanwj's comment is old enough but seems related:

    As I've said before many times, I'm not happy about statically linking qt on Linux - and certainly not everything it depends on like font libraries. This should be up to the system. This will mess up appmenu integration in Ubuntu, for example, and other distro-specific customization.

  11. hebasto commented on Aug 12, 2020

    @hebasto
    MemberAuthor

    Could missed GTK+ support cause this bug?

    It seems missed GTK+ support does not cause this bug.
    I've configured and compiled static Qt with

    Qt Widgets:
      GTK+ ................................... yes
      Styles ................................. Fusion Windows
    

    then compiled bitcoin-qt with statically linked Qt:

    $ ldd src/qt/bitcoin-qt | grep -i qt
    # empty output
    $ src/qt/bitcoin-qt -regtest -printtoconsole
    2020-08-12T11:25:36Z [main] Bitcoin Core version v0.20.99.0-7c8e2ecf0 (release build)
    2020-08-12T11:25:36Z [main] Qt 5.9.8 (static), plugin=xcb (static)
    2020-08-12T11:25:36Z [main] System: Linux Mint 20, x86_64-little_endian-lp64
    2020-08-12T11:25:36Z [main] Screen: HDMI-2 1600x1200, pixel ratio=1.0
    ...
    

    and a widget-based QFileDialog is still openning.

  12. hebasto commented on Jun 24, 2021

    @hebasto
    MemberAuthor

    Here is another observation. A non-native QFileDialog requires ICU support, but it is disabled:

    $(package)_config_opts += -no-icu

    As a consequence, users experience Qt warnings every time they open a filesystem dialog:

    2021-06-23T15:48:26Z GUI: Case insensitive sorting unsupported in the posix collation implementation
    2021-06-23T15:48:26Z GUI: Numeric mode unsupported in the posix collation implementation
    

    Just removing -no-icu is not an option as it introduces new dependencies and exported symbols.

  13. added a commit that references this issue on Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugLinux

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions