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. [Solved]who change image's view and style
Qt 6.11 is out! See what's new in the release blog

[Solved]who change image's view and style

Scheduled Pinned Locked Moved QML and Qt Quick
12 Posts 5 Posters 7.9k Views 1 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.
  • B Offline
    B Offline
    bellnas
    wrote on last edited by
    #1

    hi,guys,I have a scene where to show some pictures,
    @
    import QtQuick 1.0

    Item {
    id: window
    width: 500; height: 200
    property int i: 0
    property string google: "http://www.google.com/logos/2011/labariceporridgefestival11-hp.jpg"
    property string yahoo: "http://l.yimg.com/a/i/brand/purplelogo/uh/us/games.gif"
    property string qt: "http://developer.qt.nokia.com/images/qtdn/frontpage-bottom-left-square-qt.png"

    Image{ id: logo
        //anchors{ fill: parent; margins: 40}
    

    x: 40; y: 40
    source : google
    fillMode: Image.PreserveAspectFit//.PreserveAspectCrop;//Stretch;//

    MouseArea {
    anchors.fill: parent
    onClicked: {
    i = i + 1
    if(i % 3 == 0)
    logo.source = yahoo
    if(i % 3 == 1)
    logo.source = google
    if(i % 3 == 2)
    logo.source = qt
    }
    }
    }
    Rectangle {
    anchors.fill: logo
    color: "Transparent"
    border{color: "steelblue";width: 2}
    }
    }
    @
    there are two or more size images,

    when switch between images , something changed ...
    I want to show them clearly
    Any ideas?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kamalakshantv
      wrote on last edited by
      #2

      The problem you are facing is not clear from your post. Do you mean that when changing two images the aspect ratio is not maintained or something similar

      1 Reply Last reply
      0
      • B Offline
        B Offline
        bellnas
        wrote on last edited by
        #3

        I want show images clearly when changing, but now image deformed, and I dont't know image's real size ,
        you can see, the first time and second time image is I want, but following image deformed,

        1 Reply Last reply
        0
        • B Offline
          B Offline
          blam
          wrote on last edited by
          #4

          What do you mean by "clearly"? The code does not stretch any of the images, so the images appear to be displayed correctly. Do you want to display them all with the same width and height?

          Also I noticed you have set the Image fillMode, but this would not be doing anything at the moment as the Image width/height properties have not been set, and so it is being automatically sized to the width/height of the source image.

          1 Reply Last reply
          0
          • B Offline
            B Offline
            bellnas
            wrote on last edited by
            #5

            you can see here, 5 snapshots when click

            http://www.flickr.com/photos/42560763@N06/5348376323/
            http://www.flickr.com/photos/42560763@N06/5348376339/
            http://www.flickr.com/photos/42560763@N06/5348376347/
            http://www.flickr.com/photos/42560763@N06/5348376363/
            http://www.flickr.com/photos/42560763@N06/5348376373/

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mbrasser
              wrote on last edited by
              #6

              Hi,

              The example seems to work fine for me, working off of the qtquick11 branch, so most likely it is a bug that has been fixed, but not yet released.

              As a workaround, does getting rid of the fillMode altogether fix things for you?

              Regards,
              Michael

              1 Reply Last reply
              0
              • B Offline
                B Offline
                bellnas
                wrote on last edited by
                #7

                Oh.
                fillMode , all enum value has problem

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mbrasser
                  wrote on last edited by
                  #8

                  If you don't use any fillMode at all (i.e. remove the fillMode) does it work correctly for you?

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    mohsen
                    wrote on last edited by
                    #9

                    you may also use states to switch between different views http://doc.qt.nokia.com/4.7-snapshot/qdeclarativestates.html

                    even, it's more easy to do with latest Qt Creator.

                    1 Reply Last reply
                    0
                    • B Offline
                      B Offline
                      bellnas
                      wrote on last edited by
                      #10

                      No.
                      because default value is Stretch and I test all enum value which has the same problem.
                      Just like no guys encounter the problem , I used qt4.7.1 release version, windows7 and ubuntu10.10

                      [quote author="mbrasser" date="1294911036"]If you don't use any fillMode at all (i.e. remove the fillMode) does it work correctly for you?[/quote]

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        mbrasser
                        wrote on last edited by
                        #11

                        [quote author="bellnas" date="1294927630"]No.
                        because default value is Stretch and I test all enum value which has the same problem.
                        [/quote]

                        Okay. Unfortunately you will probably need to wait for an upcoming release where this is fixed for a nice solution. I've been able to hack it to work for me in 4.7.1 by setting

                        @
                        logo.source = ""
                        logo.sourceSize = "0x0"
                        @

                        each time before setting the source.

                        Regards,
                        Michael

                        1 Reply Last reply
                        0
                        • B Offline
                          B Offline
                          bellnas
                          wrote on last edited by
                          #12

                          Thanks mbrasser.
                          you are great and you are much 给力

                          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