首页 > 编程知识 正文

绘制自定义按钮,自定义按钮怎么设置

时间:2023-05-03 21:53:05 阅读:54950 作者:1885

一、引言在qml开发中,本文总结了实现自己在开发中比较喜欢的自定义按钮的两种方式。

(1)蓝牙状态

)2)图像鼠标区域

【效果如下】

-

二、自定义按钮2-1、通过映射方式实现自定义按钮(直接上传代码) ) ) ) ) ) ) ) )。

//【实现蓝牙】

importqtquick 2.10 importqtquick.templates 2.1 astt.button { id : controlimplicitwidth 3360 math.max (背景? 背景. implicit width :00, iconon.implicitwidthleftpaddingrightpadding ) implicit height 3360 math.max (background.implicit height 3360, iconon.implicitheighttoppaddingbottompadding ) 左填充33604 right填充:4 text : control.statepropertyaliasiconoffsource 3360 iconoff.sourcepropertyaliasicononsource 60 false checkable : true image { id : icono NX : y : source :’qrc :/asserts/imager setting _ normal.png ' } 为image { id : icon offx : y : source : ' qrc :/asserts/images/setting _ checked按钮创建“已选择”和“常规”两种状态状态state { name : ' checked ' when : control.checkedpropertychanges { target : iconoffvisible 3360 false },//常规测试控制. checked! control.hoveredpropertychanges { target : icononvisible : false }

//【实现image mouse area】

importqtquick 2.4 importqtquick.controls 2.0 importqtquick.layouts 1.3 image { id : root source : ' qrc :/asserts/imats settings icon.png ' signalclickedpropertyintduration 3360500 propertyaliastext 3360 label.textmousearea { anchors.fill 3360 } margin :-29 on clicked : root.clicked (on pressed : ) glow.visible=true animation1. start (动画2 .开始) ) x :34 y :39 visible : false width :250 height :250 color : ' # 0000000 ' radius :125 scale :1.05 border.color label { id : labelx :292 y :328 text 3360 qstr () ) : anchors.horizontal center : parent.horizontal centerconter ts.font family font.pint alcenteroffset :0} property animation { target : glow id : animation1duration : root.duration loops :1 from :1.05 to 3:1 property 3360.1 imation2sequential animation } property animation { target : glow duration : root.duration looppion.2to :1.0 property 333: 属性动画{ target : glow duration : root.duration loops :1 from :0 to :0 property : ' opacity } 属性操作{ target : glow property : ' visible ' value : false } sequential animation { property action } target : glow property 3360 ' border.width ' value :50 } pause animation { duration } property animation { target : glow dode

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。