[Solved]who change image's view and style
-
hi,guys,I have a scene where to show some pictures,
@
import QtQuick 1.0Item {
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? -
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
-
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.
-
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/ -
-
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.
-
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]
-
[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