当前位置:网站首页>Custom QML control: imagebutton
Custom QML control: imagebutton
2022-07-29 05:23:00 【Shangguan Hongzhu】
Customize Qml Control :ImageButton
effect
Let's define a ImageButton Control , namely Button Add a Image picture , both Button Click events for , At the same time, three states are added : The normal state 、 Hover state 、 Press state .
The effect is as follows :
normal <-> hover :
Pressing effect :
Realize the idea
Define a
RectangleInside contains aImage, Used to show picturesRectangle{ Image { id:bk_image anchors.fill: parent } }The picture fills the whole
Rectangle, You can also add a pair ofRectangleDecoration of edges , This depends on the individual project .Define a
MouseAreaUsed to receive mouse eventsreceive :
entered、exited、pressedThree events , Change in the corresponding eventRectangleOfstatevalue , This triggers a state transition .Define a
statesIt is used to update pictures during state transitionstatesFor specific usage, please refer to Qml type :State state chapter .In each state, we need to change two things : One is
ImagePicture source , The other isRectangleTransparency . So each of theseStateYou need twoPropertyChanges, Form the following :State { name: "normal" // Status name PropertyChanges { target: bkImage // Target control ID source: rootRect.normal_url // The properties of the target control that need to be changed } PropertyChanges{ target: rootRect opacity: noramlOpacity } }
The complete implementation can search official account through wechat :“ Shangguan Hongzhu ”, Or scan the QR code below , Pay attention to and reply to :“ImageButton”, Get resource links . If you have any questions, you can also leave a message in official account .
边栏推荐
猜你喜欢

基于注解的三层项目的改造及添加包扫描的方式

Self join and joint query of MySQL

js(forEach)出现return无法结束函数的解决方法

OCCT学习001-----简介

2022年SPSSPRO认证杯数学建模B题第二阶段方案及赛后总结

Unity metaverse (III), protobuf & socket realize multi person online

Handwritten student management system

容器安全开源检测工具--问脉 VeinMind(镜像后门、恶意样本、敏感信息、弱口令等)

Arfoundation starts from scratch 3- create an arfoundation project

Pivot table of odoo development tutorial
随机推荐
CryEngine5 Shader调试
千人规模互联网公司研发效能成功之路
Qml类型:MouseArea
CMU15-213 Malloc Lab实验记录
osg进阶-序
Self join and joint query of MySQL
C语言求字符串的长度
C 语言手写 QQ-AI 版
QT series - Installation
vs2019编译cryengine失败问题处理
Open the tutorial of adding and modifying automatically playing music on the open zone website
The method and detailed code of automatically pop-up and QQ group when players visit the website
The latest tank battle 2022 full development notes-1
js(forEach)出现return无法结束函数的解决方法
D3d Shader Instruction
Learn the first program of database
osgSimplegl3例子分析
Mysql把查询到的结果集按指定顺寻进行排序
数据泄漏、删除事件频发,企业应如何构建安全防线?
Is Huatai Securities an AA level securities company? How about this company? Is it safe to open an account?