[Solved] How to use qml to display a specified part of a picture
-
wrote on 3 Oct 2011, 08:26 last edited by
could anyone tall me how to do this in qml? Just like background-position in CSS.
-
wrote on 3 Oct 2011, 09:02 last edited by
Can you explain a bit more? You want to display a piture in some position on the screen or you want to display some part of image?
Taka a look at "Image.fillMode":http://doc.qt.nokia.com/4.7-snapshot/qml-image.html#fillMode-prop
-
wrote on 3 Oct 2011, 11:31 last edited by
Hmmm, not sure of any built in way of doing this. You may need to write your own custom item in C++ and expose this to the QML context. It should be relatively simple to do.
-
wrote on 3 Oct 2011, 11:55 last edited by
I want to display some part of a image, and I guess the only way to do it is pointed out by ZapB~ Thank u for replying!
[quote author="task_struct" date="1317632528"]Can you explain a bit more? You want to display a piture in some position on the screen or you want to display some part of image?
Taka a look at "Image.fillMode":http://doc.qt.nokia.com/4.7-snapshot/qml-image.html#fillMode-prop[/quote]
-
wrote on 3 Oct 2011, 12:31 last edited by
hi guys, I solved this in this way!
@
Rectangle{
id: login
clip: true
width: 80
height: 25
Image {
id: loginButton
x: 80
y: 0
source: "./image/Login_btn_login.png"
}
}
@
Put an image in a rectangle change x and y of the image, until get the right part of the image! Cheers!Edit: Be sure and wrap code in @ tags; mlong
-
wrote on 3 Oct 2011, 12:38 last edited by
I`ve just wrote similar example :)
-
wrote on 3 Oct 2011, 23:36 last edited by
Hi,
Glad you found a solution for this. Note that using an Item to do the clip, rather than a Rectangle, may be slightly more efficient (a Rectangle will try to paint itself, while an Item won't).
Regards,
Michael
5/7