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. How to resize a *.png* image in a QML code
Forum Updated to NodeBB v4.3 + New Features

How to resize a *.png* image in a QML code

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 3.0k Views
  • 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.
  • tomyT Offline
    tomyT Offline
    tomy
    wrote on last edited by
    #1

    Hi all,

    For an image in a QML project, I need to have some manipulation which is resizing that image so that it meets the needs for its appearance.
    I use these:

    Image {
            id: background
            source: "qrc:/images/background.png"
            paintedWidth: 200
            paintedHeight: 200
           // fillMode: Image.PreserveAspectFit
    
        }
    

    But it doesn't have any effect on the actual image when the program is run.

    ODБOïO 1 Reply Last reply
    0
    • tomyT tomy

      Hi all,

      For an image in a QML project, I need to have some manipulation which is resizing that image so that it meets the needs for its appearance.
      I use these:

      Image {
              id: background
              source: "qrc:/images/background.png"
              paintedWidth: 200
              paintedHeight: 200
             // fillMode: Image.PreserveAspectFit
      
          }
      

      But it doesn't have any effect on the actual image when the program is run.

      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by
      #2

      hi
      @tomy said in How to resize a *.png* image in a QML code:

      paintedWidth: 200
      paintedHeight: 200
      

      set

      width: 200
      height: 200
      
      tomyT 1 Reply Last reply
      2
      • ODБOïO ODБOï

        hi
        @tomy said in How to resize a *.png* image in a QML code:

        paintedWidth: 200
        paintedHeight: 200
        

        set

        width: 200
        height: 200
        
        tomyT Offline
        tomyT Offline
        tomy
        wrote on last edited by
        #3

        @LeLev
        Thanks so much.
        It solved the problem.
        At the commencement, I didn't test this because I thought it's very easy and couldn't work! So I went after the advanced stuff written above but it was them which didn't work in effect and this easy version is very handy! :)

        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