[Solved]who change image’s view and style
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"
- 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)
- }
- }
- }
- 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?
11 replies
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.
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
You must log in to post a reply. Not a member yet? Register here!





