January 11, 2011

bellnas bellnas
Lab Rat
11 posts

[Solved]who change image’s view and style

 

hi,guys,I have a scene where to show some pictures,

  1. import QtQuick 1.0
  2.  
  3. Item {
  4.     id: window
  5.     width: 500; height: 200
  6.  property int i: 0
  7.  property string google: "http://www.google.com/logos/2011/labariceporridgefestival11-hp.jpg"
  8.      property string yahoo: "http://l.yimg.com/a/i/brand/purplelogo/uh/us/games.gif"
  9.  property string qt: "http://developer.qt.nokia.com/images/qtdn/frontpage-bottom-left-square-qt.png"
  10.    
  11.     Image{ id: logo
  12.         //anchors{ fill: parent; margins: 40}
  13.  x: 40; y: 40
  14.  source : google
  15.  fillMode: Image.PreserveAspectFit//.PreserveAspectCrop;//Stretch;//
  16.  
  17.  MouseArea {
  18.   anchors.fill: parent
  19.   onClicked: {
  20.    i  = i + 1
  21.    if(i % 3 == 0)
  22.     logo.source = yahoo
  23.    if(i % 3 == 1)
  24.     logo.source = google
  25.    if(i % 3 == 2)
  26.     logo.source = qt
  27.   }
  28.  }
  29.     }
  30.   Rectangle {
  31.   anchors.fill: logo
  32.   color: "Transparent"
  33.   border{color: "steelblue";width: 2}
  34.  }
  35. }

there are two or more size images,

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

11 replies

January 11, 2011

QtK QtK
Lab Rat
1045 posts

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

January 12, 2011

bellnas bellnas
Lab Rat
11 posts

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,

January 12, 2011

blam blam
Lab Rat
58 posts

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.

January 12, 2011

bellnas bellnas
Lab Rat
11 posts

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/

January 13, 2011

mbrasser mbrasser
Lab Rat
452 posts

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

January 13, 2011

bellnas bellnas
Lab Rat
11 posts

Oh.
fillMode , all enum value has problem

January 13, 2011

mbrasser mbrasser
Lab Rat
452 posts

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

January 13, 2011

Mohsen Mohsen
Lab Rat
685 posts

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.

 Signature 

www.madagon.com

January 13, 2011

bellnas bellnas
Lab Rat
11 posts

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

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

January 14, 2011

mbrasser mbrasser
Lab Rat
452 posts
bellnas wrote:
No. because default value is Stretch and I test all enum value which has the same problem.

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

  1. logo.source = ""
  2. logo.sourceSize = "0x0"

each time before setting the source.

Regards,
Michael

January 14, 2011

bellnas bellnas
Lab Rat
11 posts

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

 
  ‹‹ animating anchors.bottom change      QDeclarativeItem modify anchor from C++ ››

You must log in to post a reply. Not a member yet? Register here!