Qml Image 截取一部分

KingRama 2015-09-22 11:19:43
Windows界面 qml里的 Image, 属性 source 可以实现贴图 怎么能截取图片的一部分进行显示 , QPainter.drawImage 就可以实现。 qml中怎么实现 如图截取四分之一
...全文
905 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
Qt_Min 2017-04-24
  • 打赏
  • 举报
回复
Rectangle { id:systemButtonFour property string pictureSource: "./btn_big.png" property int copies: 4 color: "transparent" signal clicked state:"normal" clip: true Image { id:picture width: systemButtonFour.width*4 height: systemButtonFour.height fillMode: Image.Stretch source: pictureSource; x: 0; y: 0; } MouseArea { hoverEnabled: true anchors.fill: parent onEntered: systemButtonFour.state == "pressed" ? systemButtonFour.state = "pressed" : systemButtonFour.state = "hover" onExited: systemButtonFour.state == "pressed" ? systemButtonFour.state = "pressed" : systemButtonFour.state = "normal" onPressed: systemButtonFour.state = "pressed" onReleased: { systemButtonFour.state = "normal" systemButtonFour.clicked() } } states: [ State{ name:"hover" PropertyChanges { target: picture x:-systemButtonFour.width } }, State { name: "normal" PropertyChanges { target: picture x:-0 } }, State { name: "pressed" PropertyChanges { target: picture x:-systemButtonFour.width*2 } } ] }
luoyayun361 2016-02-17
  • 打赏
  • 举报
回复
你好,我也遇到这个问题,可以详细的说一下解决办法吗 ,没看懂啊。谢谢了
KingRama 2015-10-27
  • 打赏
  • 举报
回复
已经解决 通过 Item的 clip裁剪 变换Image的 x 坐标实现 Rectangle{ anchors.fill: parent; color:"transparent"; clip:true; Image{ id: btnImage ; x:0; y:0; } }
han0956 2015-09-27
  • 打赏
  • 举报
回复
用画布Canvas剪裁你需要的任意图片,找个例子看看!
KingRama 2015-09-22
  • 打赏
  • 举报
回复
是不是Image里没截取的接口,Button对象里 我也没发现这样的接口, 那怎么实现Button的 状态切换呢(一张图片)
KingRama 2015-09-22
  • 打赏
  • 举报
回复
自己顶一下 有大神看到了么

16,239

社区成员

发帖
与我相关
我的任务
社区描述
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
社区管理员
  • Qt
  • 亭台六七座
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧