QML列表视图中选择项目亮点上点击

编程入门 行业动态 更新时间:2024-10-19 18:33:03
本文介绍了QML列表视图中选择项目亮点上点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

您好我想把这个code:

Hi I want to put this code :

highlight: Rectangle { color: "black" radius: 5 opacity: 0.7 focus: true }

到鼠标区域在onclick处理程序:

into mouseArea in onclick handler:

MouseArea { id: mouse_area1 z: 1 hoverEnabled: false anchors.fill: parent onClicked: { }

这是所有的ListView:

This is all listView:

ListView { id: listview1 x: 0 y: 82 // width: 574 // height: 967 width: window.width height: window.height visible: true keyNavigationWraps: false boundsBehavior: Flickable.DragAndOvershootBounds opacity: 1 maximumFlickVelocity: 2500 anchors.leftMargin: 0 highlightMoveSpeed: 489 contentWidth: 0 preferredHighlightEnd: 2 spacing: 5 highlightRangeMode: ListView.NoHighlightRange snapMode: ListView.SnapToItem anchors.bottomMargin: 0 anchors.rightMargin: 0 anchors.topMargin: 82 anchors.fill: parent model: myModel delegate:Component { //id: contactDelegate Item { property variant myData: model width: 574; height: 90 Column { x: 12 y: 0 width: 562 height: 90 anchors.rightMargin: 0 anchors.bottomMargin: 0 anchors.leftMargin: 12 anchors.topMargin: 0 anchors.fill: parent spacing: 2 Text { text: '<b>ID: </b> ' + id_user ; verticalAlignment: Text.AlignTop; wrapMode: Text.NoWrap; horizontalAlignment: Text.AlignHCenter; color:"steelblue"; font.family: "Helvetica"; font.pointSize: 10 } Text { text: '<b>Name: </b> ' + user_name; horizontalAlignment: Text.AlignHCenter; color:"steelblue"; font.family: "Helvetica"; font.pointSize: 10 } Text { text: '<b>Lastname: </b> ' + user_lastname; horizontalAlignment: Text.AlignHCenter; color:"steelblue"; font.family: "Helvetica"; font.pointSize: 10 } Text { height: 16; text: '<b>Tel number: </b> ' + user_number; verticalAlignment: Text.AlignVCenter; horizontalAlignment: Text.AlignHCenter; color:"steelblue"; font.family: "Helvetica"; font.pointSize: 10 } Text { text: '<b>Address: </b> ' + user address; horizontalAlignment: Text.AlignHCenter; color:"steelblue"; font.family: "Helvetica"; font.pointSize: 10 } MouseArea { id: mouse_area1 z: 1 hoverEnabled: false anchors.fill: parent onClicked: Item { } } } } } //delegate: contactDelegate highlight: Rectangle { color:"black" radius: 5 opacity: 0.7 focus: true } }

有关使用现在时,箭头亮点是唯一的工作,bbut这将是Android应用程序,所以我需要在触摸同样的效果,第二个问题是如何从选择的项目列表视图中读取某些数据?里面我有这样的ID,姓名,姓氏,编号和地址,。我希望把这些值转换成TEXT_INPUT框。

For now highlight is working only when using arrows, bbut this will be app for android so I need on touch that same effect, and SECOND question is how to read certain data from selected item in listview? Inside I have like id,name,lastname,number and adress. I want to put those values into text_input boxes.

感谢您

推荐答案

答所提供 denoth :在您需要添加该行:

Answer provided by denoth: You need to add this line:

listview1.currentIndex = index

更多推荐

QML列表视图中选择项目亮点上点击

本文发布于:2023-11-10 22:20:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1576615.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:视图   亮点   项目   列表   QML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!