import QtQuick 2.15 import QtQuick.Controls import QtQuick.Layouts import Qt5Compat.GraphicalEffects import ESP32_upper 1.0 Item { Component { id: contactDelegate Rectangle { width: 60; height: 60 radius: 5 color: id_gp.left_menu_non_lighlight_color MouseArea { id: mouseArea anchors.fill: parent hoverEnabled: true onClicked: { // id_view.view.currentIndex = index id_gp.left_menu_index_last = id_gp.left_menu_index_now id_gp.left_menu_index_now = index id_view.currentIndex = index id_layout_right_panel.currentIndex = index // console.log("left_menu_index", id_gp.left_menu_index_now) } onEntered: { if (index != id_gp.left_menu_index_now) { id_view.itemAtIndex(index).color = id_gp.left_menu_focus_color } id_lm_tooltip_text.text = name; id_lm_tooltip.visible = true; } onExited: { if (index != id_gp.left_menu_index_now) { id_view.itemAtIndex(index).color = id_gp.left_menu_non_lighlight_color } id_lm_tooltip.visible = false; } Rectangle { color: "transparent" // 设置背景为透明 width:50 ; height:50 anchors.centerIn : parent Image { id:svgIMG source: qrc_path width: parent.width height: parent.height smooth: true // 使图片平滑缩放 asynchronous: true // 异步加载图片 } // 使用 ColorOverlay 修改 SVG 颜色 ColorOverlay { anchors.fill: svgIMG source: svgIMG color: id_gp.left_menu_icon_color // 修改后的 SVG 图片颜色 } } ToolTip { id: id_lm_tooltip delay: 1000 timeout: 5000 width: 60 height: 30 // text: "" // 初始文本为空 opacity: 0.7 background: Rectangle { color: "#e70e0e" anchors.fill: parent border.color: "#e70e0e" radius: 10 Text { anchors.centerIn: parent id: id_lm_tooltip_text text: "" font.pixelSize: 20 color: "#0e0606" } } } } } } MouseArea { anchors.fill: parent onWheel: (wheel) => { wheel.accepted = true; // 处理滚轮事件并阻止事件传递 id_view.contentY += wheel.angleDelta.y / 120 * 10; // 根据滚轮的滚动方向和量来滚动 ListView } ListView { id: id_view spacing: 10 topMargin: 10 leftMargin: 10 anchors.fill: parent model: TestModels {} delegate: contactDelegate flickDeceleration: 0 // 禁止滚动时的伸缩效果 clip : true snapMode: ListView.SnapToItem onCurrentIndexChanged: { // console.log("2 left_menu_index", id_gp.left_menu_index_now) itemAtIndex(id_gp.left_menu_index_last).color = id_gp.left_menu_non_lighlight_color itemAtIndex(id_gp.left_menu_index_now).color = id_gp.left_menu_lighlight_color } Component.onCompleted: { console.log("complete at ", id_gp.left_menu_index_now) id_timer_leftmenu.start() } } } Timer { id: id_timer_leftmenu interval: 500 // 1秒 repeat: true running: true triggeredOnStart: false onTriggered: { // 这里执行你的轮询逻辑,比如调用一个函数来获取数据 if (id_gp.gp_inited == 1) { running = false; id_gp.left_menu_index_last = id_view.count id_gp.left_menu_index_now = 0 id_view.itemAtIndex(id_gp.left_menu_index_now).color = id_gp.left_menu_lighlight_color } else { pollForData(); console.log("id gp ini : " , id_gp.gp_inited ) } } } function pollForData() { // 实现数据获取逻辑,例如通过网络请求获取数据 console.log("Polling for new data..."); } }