Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-62323

No way to set disclosure widget size on QTreeView; too small on high-DPI devices

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.10.0 Alpha
    • 5.9.1
    • None
    • Qt 5.9.1

      Generic Linux (Ubuntu 16.04.2 LTS)

      Generic Android (Android 6.0.1 on a Samsung Galaxy S5 Neo)
    • 63d08003cf06b84b871618ba800a7079ae6bf702

    Description

      When using QTreeView, there appears to be no way to set the size of the disclosure widget (the rotating triangle at the left that shows whether branches are expanded or collapsed), at least in the Fusion style.

      The result is that the triangles can appear very small on high-DPI touchscreens, and so be very hard to touch accurately. Attached is a screenshot from Linux at 96 DPI (fine) and Android at 216 DPI (tiny) - the font sizes are corrected for DPI, and in both cases the arrow is about 9 px high, so that's about 2.4mm on the 96dpi monitor (when it doesn't really matter because the user has a mouse) and about 1mm on the 216dpi touchscreen, when it really does.

      The arrow is set by

       

      arrow = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"), arrowColor, rotation);
      

      at line 531 of qfusionstyle.cpp.

      This section doesn't call its proxy(), so there's no way that I can see to use a QProxyStyle to alter this behaviour. Indeed, if you apply a proxy style whose drawPrimitive() function does nothing when its element is one of QStyle::PE_IndicatorArrowUp, QStyle::PE_IndicatorArrowDown, QStyle::PE_IndicatorArrowRight, or QStyle::PE_IndicatorArrowLeft, it is called occasionally but never, it seems, in a critical way (because doing nothing doesn't prevent the arrows being drawn). Nor is there any call to the style's proxy() in the preceding drawPrimitive call with PE_IndicatorBranch, which decides which version of the arrow to draw.

      Moreover, the arrow size is forced to the minimum of the image size and the available space, if I read it right, around lines 535-542 of qfusionstyle.cpp.

      Nor does setting a custom delegate on the QTreeView appear to provide anything useful.

      I would like to be able to set the arrow programmatically (from C++, not stylesheets), as the DPI setting is known only at runtime. Am I missing something? Thank you!

      Attachments

        1. android_216_dpi.png
          android_216_dpi.png
          192 kB
        2. linux_96dpi.png
          linux_96dpi.png
          96 kB
        3. simpletreemodel.png
          simpletreemodel.png
          168 kB

        Issue Links

          Activity

            People

              richard Richard Moe Gustavsen
              rudolf@pobox.com Rudolf Cardinal
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: