《QT实用小工具·三十三》Qt/QML做的一个仿手机通讯录界面

本文介绍了如何使用代码实现一个手机通讯录应用的界面,包括ListView的分组和排序,以及提供了一个示例代码段。文章最后附有源码下载链接。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、概述
源码放在文章末尾

该项目实现了手机通讯录的功能,界面demo如下所示:
在这里插入图片描述
项目部分代码如下所示:

//联系人列表
    Item{
        width: parent.width
        height: parent.height
        anchors.centerIn: parent


        Rectangle{
            anchors.fill: parent
            color: "#2A2D33"
        }

        Component {
            id:sectionHeader
            Item {
                width: 100
                height: 120

                Text {
                    //                    anchors.verticalCenter: parent.verticalCenter
                    text: section.toUpperCase()/*.substr(0, 1)*/
                    font.pixelSize: 54
                    anchors.left: parent.left
                    anchors.leftMargin: 40
                    color: "#545a66"
                    anchors.bottom: parent.bottom
                }
            }
        }




        ListView{

            //listview的分组不会自动排序
            width:parent.width;height: parent.height-130
            anchors.bottom: parent.bottom
            clip: true
            id:listView
            //            spacing:20

            model: testModel
            delegate: Item {
                height: 120
                width: parent.width
                Text {
                    text: listView.getShowTextSpecial(name)
                    anchors.verticalCenter: parent.verticalCenter
                    color: "#858fa2"
                    font.pixelSize: 45
                    x:40
                }
                Rectangle{
                    anchors.bottom: parent.bottom
                    color: "#1a1c20"
                    width: parent.width
                    height: 1
                }
            }

            ScrollIndicator.vertical: ScrollIndicator {
                anchors.right: parent.right
                anchors.rightMargin: 10
                contentItem: Rectangle {
                    implicitWidth: 8
                    radius: implicitWidth/2
                    color: "#0f1115"
                }
            }

            function getShowTextSpecial(str){
                var first = str[0];
                if (first === "#")
                    return str.substr(1);
                return str;
            }


            section.property: "pinyin";
            section.criteria: ViewSection.FirstCharacter //ViewSection.FirstCharacter//
            section.delegate: sectionHeader

        }

源码下载

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

梦回阑珊

一毛不嫌多,一分也是爱

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值