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

issue hebasto opened this issue on July 15, 2020
  1. hebasto commented at 9:21 AM on July 15, 2020: member

    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.

  2. hebasto added the label Bug on Jul 15, 2020
  3. hebasto commented at 9:28 AM on July 15, 2020: member

    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:

  4. MarcoFalke commented at 9:44 AM on July 15, 2020: contributor

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

  5. hebasto commented at 9:47 AM on July 15, 2020: member

    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.

  6. ryanofsky commented at 9:51 AM on July 15, 2020: contributor

    Nice find!

  7. hebasto commented at 5:38 PM on July 16, 2020: member

    @MarcoFalke

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

    A: https://github.com/bitcoin/bitcoin/pull/19536

  8. hebasto commented at 6:14 PM on August 9, 2020: member

    UPDATE: such behavior observed on Linux only.

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

  9. fanquake commented at 5:51 AM on August 10, 2020: member

    UPDATE: such behavior observed on Linux only.

    I thought this was fixed by https://github.com/bitcoin/bitcoin/pull/19536?

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

    Right, I see these are separate.

  10. hebasto commented at 4:56 PM on August 10, 2020: member
    $ 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?

  11. hebasto commented at 7:30 PM on August 11, 2020: member

    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.

  12. hebasto commented at 11:36 AM on August 12, 2020: member

    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.

  13. hebasto added the label Linux on Mar 5, 2021
  14. hebasto commented at 4:28 AM on June 24, 2021: member

    Here is another observation. A non-native QFileDialog requires ICU support, but it is disabled: https://github.com/bitcoin-core/gui/blob/7317e14a44c6efc545e6fb9bcedee7174e93a8fa/depends/packages/qt.mk#L40

    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.


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/gui. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-14 21:20 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me