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

Add a `icon.fillMode` property to icons in QtQuick Controls 2

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • P4: Low
    • None
    • 5.12.0, 5.12.1, 5.12.2, 5.12.3
    • Quick: Controls 2
    • None
    • All

    Description

      If the icon to show doesn't have square dimensions, it's stretched. That's doesn't look well, so I suggest adding a icon.fillMode (like Image.fillMode) property to the controls that support icons.

      UPDATE

      As mitch_curtis suggested, I will add a working example:

      Consider the two following SVG icons:

      0.svg

       

      <svg width="512" height="256">
       <circle cx="256" cy="128" r="96" style="fill: red; stroke: black; stroke-width: 24"/>
      </svg>

       

      1.svg

       

      <svg width="256" height="512">
       <circle cx="128" cy="256" r="96" style="fill: blue; stroke: black; stroke-width: 24"/>
      </svg> 

       

      And the following main.qml:

      main.qml

      import QtQuick 2.15
      import QtQuick.Controls 2.15
      import QtQuick.Window 2.15
      
      Window {
          ComboBox {
              anchors.centerIn: parent
              model: 2
              delegate: MenuItem {
                  width: parent.width
                  text: "Index " + modelData
                  icon.source: index + ".svg"
                  icon.color: "transparent"
              }
          }
      }
      

      Despite the icons are both circles, when running the above example with qmlscene this is what we obtain:

       

      Attachments

        1. IconFillMode.tar.gz
          0.5 kB
        2. IconFillMode-cmake.zip
          2 kB
        3. Screenshot_20200903_175445.png
          Screenshot_20200903_175445.png
          22 kB
        4. screenshot-1.png
          screenshot-1.png
          7 kB

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              ceperez1996 Carlos Pérez
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes