当前位置:网站首页>QML type: mousearea
QML type: mousearea
2022-07-29 05:22:00 【Shangguan Hongzhu】
Qml type :MouseArea
MouseArea Transparent transmission of mouse click events
Realization MouseArea
Transparent , Let the mouse event pass from the parent control to the child control .
Set up two Rectangle
,rect1
and rect2
,rect1
yes rect2
The parent control of , And the area of the child control is the same as that of the parent control , The following code ( A rectangular area displayed in orange , The red parent control is covered by the orange child control ). If you implement a that overrides the entire parent control in the parent control MouseArea
Click events for , So by default , Only the parent control receives the click event , The child control will not receive the click event .
When the child control needs to receive the click message of the parent control , Of the parent control MouseArea
Two things need to be done :
- 1、 Set up
propagateComposedEvents
bytrue
, This attribute indicates whether the combined mouse event will be automatically propagated to thisMouseArea
Others that overlap but are visually stacked in a lower orderMouseArea
. By default , This property is false. - 2、 stay
MouseArea
Set in message processing ofMouseEvent::accepted
byfalse
, It means to let the current event continue to pass down .
Rectangle {
id: rect1
width: 328
height: 32
color: "red"
Rectangle {
id: rect2
anchors.fill: parent
color: "orange"
MouseArea {
anchors.fill: parent
onClicked: {
console.log("rect2 clicked 22")
}
}
}
MouseArea {
anchors.fill: parent
propagateComposedEvents : true // 1.
onClicked: {
console.log("rect1 clicked 333")
mouse.accepted = false // 2.
}
}
}
The above code mouse.accepted = false
Medium mouse
Where did it come from ?
This mouse
yes onClicked
Corresponding to slot function clicked
Parameters carried by the signal ,clicked
The declaration of the signal is :clicked(MouseEvent mouse)
.
If you want to let MouseArea Do not accept mouse events can be set acceptedButtons
by Qt.NoButton
.
Please use wechat official account to search :“ Shangguan Hongzhu ”, Or scan the QR code below , Background message consultation .
边栏推荐
- SQL log
- 玩家访问网站自动弹窗加QQ群方法以及详细代码
- 直播预告|如何节省30%人工成本,缩短80%商标办理周期?
- What is_ GLIBCXX_ VISIBILITY(default)
- The latest tank battle 2022 full development notes-1
- 365天挑战LeetCode1000题——Day 038 公交站间的距离 + 基于时间的键值存储 + 转变数组后最接近目标值的数组和 + 有界数组中指定下标处的最大值
- 7.3-function-templates
- roLabelImg转DATO格式数据
- Qml类型:State 状态
- 使用Jstack、Jconsole和jvisualvm进行死锁分析
猜你喜欢
6.3 references
Adb常用命令列表
ARFoundation入门教程7-url动态加载图像跟踪库
C language handwritten qq-ai version
Open source Huizhi creates the future | the openeuler sub forum of 2022 open atom global open source summit was successfully held
Mysql多对多关系,分组拼接把多个数据查询到一条数据上
ARFoundation从零开始5-AR图像跟踪
365天挑战LeetCode1000题——Day 041 二分查找完结纪念 + 第 N 个神奇数字 + 在线选举
传奇服务端如何添加地图
研发效能生态完整图谱&DevOps工具选型必看
随机推荐
C语言用指向指针的指针对n个整数排序
How to add traffic statistics codes to the legendary Development Zone website
The representation of time series analysis: is the era of learning coming?
【[第一次写博客]Uda课程中的P控制器实现说明】
Teardown 解除时间限制的方法
On AspectJ framework
Ros1 dead chicken data is stored in txt and SQLite
Teardown's method of lifting the time limit
Webrtc audio anti weak network technology (Part 2)
Unity metaverse (III), protobuf & socket realize multi person online
Button for QT custom switch effect
What is_ GLIBCXX_ VISIBILITY(default)
源码编译pytorch坑
使用Jstack、Jconsole和jvisualvm进行死锁分析
什么是_GLIBCXX_VISIBILITY(default)
C 语言手写 QQ-AI 版
Legend how to configure multiple versions of wechat updates on one server
CryEngine5 Shader调试
开区网站打开自动播放音乐的添加跟修改教程
自贸经济中架起的“隐形桥梁”:国货精品与中国AI力量