第二章 快速入门—–核心元素类型

第二章 快速入门—–核心元素类型Image 元素能够以各种格式 例如 PNG JPG GIF BMP WEBP 显示图像

大家好,欢迎来到IT知识分享网。

import QtQuick import QtQuick.Window Window { width: 640 height: 480 visible: true title: qsTr("Rect") Rectangle{ id:rect1 x:12;y:12 width:76;height:96 color:"lightsteelblue" } Rectangle{ id:rect2 x:112;y:12 width:76;height:96 color:"lightsteelblue" radius:20 } Rectangle{ id:rect3 x:212;y:12 width:76;height:96 gradient: Gradient{ GradientStop{position: 0.0;color:"lightsteelblue"} GradientStop{position:1.0;color:"slategray"} } border.color:"lightsteelblue" border.width:4 radius:20 } } 
import QtQuick import QtQuick.Window Window { width: 640 height: 480 visible: true title: qsTr("Hello World") Text{ id:text1 text:"The quick brown fox" color:"#" font.family: 'Ubuntu' font.pixelSize: 28 } Text { width:40 elide: Text.ElideMiddle y:text1.y + text1.height + 20 text:"一个很长很长的句子....." style:Text.Sunken styleColor: "#FF4444" font.pixelSize: 28 color:"#" wrapMode: Text.WordWrap } } 

3、Image

import QtQuick import QtQuick.Window Window { width: 640 height: 480 visible: true title: qsTr("image") Image{ id:image1 source:"../images/pinwheel.png" } Image{ x:image1.x + image1.width + 12 width:image1.width/2 id:image2 source:"../images/pinwheel.png" fillMode: Image.Stretch } Image{ y:image1.y + image1.height + 12 width:image1.width/2 source:"../images/pinwheel.png" fillMode: Image.PreserveAspectCrop clip: true //这种模式下,需要把这个属性设置为true } } 
import QtQuick import QtQuick.Window Window { width: 640 height: 480 visible: true title: qsTr("MosueArea") Rectangle{ id:rect1 x:12;y:12 width:76;height:96 color: 'lightsteelblue' MouseArea{ width:parent.width height:parent.height onClicked: rect2.visible = !rect2.visible } } Rectangle{ id:rect2 x:112;y:12 width:76;height:96 border.color: 'lightsteelblue' border.width: 4 radius:8 } } 

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://haidsoft.com/121128.html

(0)
上一篇 2025-10-25 14:33
下一篇 2025-10-25 14:45

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注微信