当前位置:网站首页>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
Rectangle
Inside 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 ofRectangle
Decoration of edges , This depends on the individual project .Define a
MouseArea
Used to receive mouse eventsreceive :
entered
、exited
、pressed
Three events , Change in the corresponding eventRectangle
Ofstate
value , This triggers a state transition .Define a
states
It is used to update pictures during state transitionstates
For specific usage, please refer to Qml type :State state chapter .In each state, we need to change two things : One is
Image
Picture source , The other isRectangle
Transparency . So each of theseState
You 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 .
边栏推荐
- QT学习:使用JSON/XML等非ts文件实现多语言国际化
- Young freshmen yearn for more open source | here comes the escape guide from open source to employment!
- QT学习:QDropEvent拖拽事件
- Unity3d - the object is too far away to see
- 365天挑战LeetCode1000题——Day 038 公交站间的距离 + 基于时间的键值存储 + 转变数组后最接近目标值的数组和 + 有界数组中指定下标处的最大值
- Handwritten student management system
- Mysql语句中的函数
- 一文带你搞懂环绕通知@Around与最终通知@After的实现
- 小白高薪捷径-Qt开发游戏—贪吃蛇
- vs2019编译cryengine失败问题处理
猜你喜欢
7.3-function-templates
The method and detailed code of automatically pop-up and QQ group when players visit the website
CMU15-213 Shell Lab实验记录
MySQL many to many relationship, grouping and splicing to query multiple data to one data
TCP three handshakes and four waves
Qml控件:ComboBox
【文件下载】Easyexcel快速上手
QT学习:使用JSON/XML等非ts文件实现多语言国际化
Arfoundation starts from scratch 3- create an arfoundation project
321,京东言犀×NLPCC 2022挑战赛开赛!
随机推荐
The latest tank battle 2022 - Notes on the whole development -2
最新坦克大战2022-全程开发笔记-1
How to add traffic statistics codes to the legendary Development Zone website
js(forEach)出现return无法结束函数的解决方法
CryEngine3 调试Shader方法
vs2019编译cryengine失败问题处理
365天挑战LeetCode1000题——Day 036 二叉树剪枝 + 子数组和排序后的区间和 + 删除最短的子数组使剩余数组有序
源码编译pytorch坑
MySQL many to many relationship, grouping and splicing to query multiple data to one data
MySQL sorts the queried result set according to the specified sequence
Architecture analysis of three-tier project and parameter name injection of construction method
数据泄漏、删除事件频发,企业应如何构建安全防线?
2022年泰迪杯数据挖掘挑战赛C题方案及赛后总结
The latest tank battle 2022 - full development notes-3
OCCT学习003-----MFC单文档工程
Getting started with solidity
C语言连连看秒杀辅助
Functions in MySQL statements
SM integration is as simple as before, and the steps are clear (detailed)
TCP three handshakes and four waves