Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Material style is shrinking/vanishing images
Forum Updated to NodeBB v4.3 + New Features

Material style is shrinking/vanishing images

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 274 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by
    #1

    Hi all -

    I've discovered some odd behavior with the Material style. Sorry for the lengthy code snippet, but I wanted to give an elaborate representation of what I'm seeing.

    I've created a Row with 3 Buttons of different sizes. Each button contains the same image. For reference, I've also added Images with the same source.

    import QtQuick
    import QtQuick.Controls
    import QtQuick.Layouts
    
    ApplicationWindow {
        id: mainWindow
        visible: true; width: 1024; height: 768
        property real reductionFactor: 0.5
        property url imageSource: "qrc:/icons/Pump.png"
        Row {
            id: row
            height: 80; spacing: 16
    
            Button {
                id: b1
                height: row.height
                width: row.height
    
                icon {
                    source: imageSource
                    height: b1.height
                    width: height
                }
    
                background: Rectangle {
                    anchors.fill: b1
                    color: 'lightgray'
                }
            }
    
            Image {
                source: imageSource
                height: b1.height
                width: height
            }
    
            Button {
                id: b2
                height: b1.height * reductionFactor
                width: height
    
                icon {
                    source: imageSource
                    height: b2.height
                    width: height
                }
    
                background: Rectangle {
                    anchors.fill: b2
                    color: 'lightgray'
                }
            }
            Image {
                source: imageSource
                height: b2.height
                width: height
            }
    
            Button {
                id: b3
                height: b2.height * reductionFactor
                width: height
    
                icon {
                    source: imageSource
                    height: b3.height
                    width: height
                }
    
                background: Rectangle {
                    anchors.fill: b3
                    color: 'lightgray'
                }
            }
            Image {
                source: imageSource
                height: b3.height
                width: height
            }
        }
    }
    

    Using the default style (running on Windows), everything seems about right (though the images are a little smaller than I'd expected):

    default.PNG

    But when I change to Material style (in main.cpp):

        QQuickStyle::setStyle("Material");
    

    I get this:

    material.PNG

    As you can see, the 2nd button's icon is much smaller, and the 3rd button's icon disappears completely.

    This behavior also occurs when running on Android.

    So...what's going on here? Is this a bug in the Material style, or am I supposed to be performing some other configuration for the style?

    Thanks...this one is really baffling me.

    ekkescornerE 1 Reply Last reply
    0
    • mzimmersM mzimmers

      Hi all -

      I've discovered some odd behavior with the Material style. Sorry for the lengthy code snippet, but I wanted to give an elaborate representation of what I'm seeing.

      I've created a Row with 3 Buttons of different sizes. Each button contains the same image. For reference, I've also added Images with the same source.

      import QtQuick
      import QtQuick.Controls
      import QtQuick.Layouts
      
      ApplicationWindow {
          id: mainWindow
          visible: true; width: 1024; height: 768
          property real reductionFactor: 0.5
          property url imageSource: "qrc:/icons/Pump.png"
          Row {
              id: row
              height: 80; spacing: 16
      
              Button {
                  id: b1
                  height: row.height
                  width: row.height
      
                  icon {
                      source: imageSource
                      height: b1.height
                      width: height
                  }
      
                  background: Rectangle {
                      anchors.fill: b1
                      color: 'lightgray'
                  }
              }
      
              Image {
                  source: imageSource
                  height: b1.height
                  width: height
              }
      
              Button {
                  id: b2
                  height: b1.height * reductionFactor
                  width: height
      
                  icon {
                      source: imageSource
                      height: b2.height
                      width: height
                  }
      
                  background: Rectangle {
                      anchors.fill: b2
                      color: 'lightgray'
                  }
              }
              Image {
                  source: imageSource
                  height: b2.height
                  width: height
              }
      
              Button {
                  id: b3
                  height: b2.height * reductionFactor
                  width: height
      
                  icon {
                      source: imageSource
                      height: b3.height
                      width: height
                  }
      
                  background: Rectangle {
                      anchors.fill: b3
                      color: 'lightgray'
                  }
              }
              Image {
                  source: imageSource
                  height: b3.height
                  width: height
              }
          }
      }
      

      Using the default style (running on Windows), everything seems about right (though the images are a little smaller than I'd expected):

      default.PNG

      But when I change to Material style (in main.cpp):

          QQuickStyle::setStyle("Material");
      

      I get this:

      material.PNG

      As you can see, the 2nd button's icon is much smaller, and the 3rd button's icon disappears completely.

      This behavior also occurs when running on Android.

      So...what's going on here? Is this a bug in the Material style, or am I supposed to be performing some other configuration for the style?

      Thanks...this one is really baffling me.

      ekkescornerE Offline
      ekkescornerE Offline
      ekkescorner
      Qt Champions 2016
      wrote on last edited by
      #2

      @mzimmers in Material there's some padding, so the available space for your Image is smaller
      https://m2.material.io/components/buttons#specs

      ekke ... Qt Champion 2016 | 2024 ... mobile business apps
      5.15 --> 6.9 https://t1p.de/ekkeChecklist
      QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

      mzimmersM 1 Reply Last reply
      1
      • ekkescornerE ekkescorner

        @mzimmers in Material there's some padding, so the available space for your Image is smaller
        https://m2.material.io/components/buttons#specs

        mzimmersM Offline
        mzimmersM Offline
        mzimmers
        wrote on last edited by
        #3

        @ekkescorner said in Material style is shrinking/vanishing images:

        @mzimmers in Material there's some padding,

        There sure is: I put in a telltale for a button of 28 px high, and it has a padding value of 12 (!). Seems like their algorithm needs a bit of work.

        Thanks for finding that.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved