The Idea of this small project was to make a small project to learn more about how to use Images in Qt & QML
import QtQuick.LayoutsApplicationWindow{id: appWindowvisible: true....Image {id: mainImage// the image with and hight change with the Canves sizewidth: mainWindow.width - 200height: mainWindow.height - 200source: "qrc:/rec/img/profile.png"anchors.centerIn: parentfillMode: Image.PreserveAspectFitmirror: true // Boolean to flip imagehorizontalAlignment: Image.AlignHCenterverticalAlignment: Image.AlignVCenterautoTransform: trueasynchronous: trueonStatusChanged: console.log("status: " + mainImage.status)}}
we can also control the image size and crop with this code
Image {....sourceSize.width: 600sourceSize.height: 600sourceClipRect: Qt.rect(0,0,300,200)}
and last and not lees for the top left info bar I'm using small Rectangle Components with a Text Components update in real time
Rectangle {width: imgInfo.width + 20height: imgInfo.heightcolor: "#3873a7"anchors.top: parent.topanchors.left: parent.leftText {id: imgInfotext: "width: " + mainImage.width + " x height: " + mainImage.heightfont.family: "Pulpo"font.pointSize: 10font.bold: truecolor: "#d4d5d5"anchors.centerIn: parent}}
you can find more info about Qml Image Component Here : Image QML Type | Qt Quick 6.3.2
0 Comments
Post a Comment