import QtQuick import QtQuick.Controls import QtQuick.Layouts import QtQuick.Dialogs import "./common" Item { id: self Row { x: 10 y: 18 Label{ text: "数据库" font.pointSize: 11 anchors.verticalCenter: parent.verticalCenter } spacing: 10 ComboBox{ id: comboBox anchors.verticalCenter: parent.verticalCenter model: influxdbNames height: 25 currentIndex: 0 Component.onCompleted: { loadInfluxDbs() if(influxdbNames.length > 0) { console.info("influxdbNames.length > 0",influxdbNames[0]) var currentInfluxdbName = influxdbManager.getCurrentInfluxdb() comboBox.currentIndex = comboBox.find(currentInfluxdbName) setInfluxdb(currentInfluxdbName) } } onActivated: { setInfluxdb(comboBox.currentText) } MouseArea{ anchors.fill: parent propagateComposedEvents: false onPressed:(mouse)=> { loadInfluxDbs() mouse.accepted = false } } } } property var influxdbNames: [] function loadInfluxDbs() { influxdbNames = [] var influxdbs = influxdbManager.getInfo("all") for(var i = 0; i < influxdbs.length; i++) { influxdbNames.push(influxdbs[i].name) } comboBox.model = influxdbNames } function setInfluxdb(dbName) { influxdbManager.setInfluxdb(dbName) } }