当前位置:网站首页>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 .
边栏推荐
- Mysql语句中的函数
- 关于thymeleaf的配置与使用
- sql日志
- Open the tutorial of adding and modifying automatically playing music on the open zone website
- Teardown's method of lifting the time limit
- 【[第一次写博客]Uda课程中的P控制器实现说明】
- 数千个数据库、遍布全国的物理机,京东物流全量上云实录 | 卓越技术团队访谈录
- About the configuration and use of thymeleaf
- SQL log
- Helm chart for Kubernetes
猜你喜欢

JS (foreach) return cannot end the function solution

Scikit learn -- steps and understanding of machine learning application development

直播预告|如何节省30%人工成本,缩短80%商标办理周期?

QT series - Installation

一文带你搞懂环绕通知@Around与最终通知@After的实现

来!看排名一年上升16位的ClickHouse,如何在京东落地实践

365天挑战LeetCode1000题——Day 036 二叉树剪枝 + 子数组和排序后的区间和 + 删除最短的子数组使剩余数组有序

365天挑战LeetCode1000题——Day 042 数组序号转换 + 相对名次 离散化处理

QT系列---安装

直播预告:京东云DevOps与JFrog制品库的融合
随机推荐
Deep learning brush a bunch of tricks of SOTA
The latest tank battle 2022 - full development notes-3
ARFoundation从零开始3-创建ARFoundation项目
玩家访问网站自动弹窗加QQ群方法以及详细代码
QtCreator+CMake编译器设置
Visual Basic .Net 如何获取命令参数
MySQL sorts the queried result set according to the specified sequence
CMU15-213 Malloc Lab实验记录
MySQL many to many relationship, grouping and splicing to query multiple data to one data
Scikit learn -- steps and understanding of machine learning application development
AUTOSAR from introduction to proficiency 100 lectures (78) -autosar-dem module
Cache penetration, cache breakdown, cache avalanche and Solutions
什么是_GLIBCXX_VISIBILITY(default)
Functions in MySQL statements
Do you remember the process analysis and function implementation of post notification?
Self join and joint query of MySQL
京东云金秋上云特惠进行中!扫码参与活动
法线可视化
C language handwritten qq-ai version
D3d Shader Instruction