import QtQuick Row { id: root spacing: 10 // 入力プロパティ property real reading: 0 property int digits: 4 // 表示する桁数 property int decimalPlaces: 0 // 小数点以下の桁数(0なら整数) property real threshold1: 0 property real threshold2: 0 // デザイン設定(SevenSegに引き継ぐ) property color activeColor: "green" // 基本色(SevenSeg側で上書きも可) property real skewAngle: 8 property real thickness: 16 Repeater { model: root.digits SevenSeg { // 左から数えて何番目の桁かを計算 // index 0 が一番左(大きい桁) readonly property int power: root.digits - index - 1 - root.decimalPlaces value: Math.floor(Math.abs(root.reading) / Math.pow(10, power)) % 10 // 小数点の位置判定 showDot: (root.decimalPlaces > 0 && power === 0) // 共通プロパティの流し込み reading: root.reading threshold1: root.threshold1 threshold2: root.threshold2 skewAngle: root.skewAngle thickness: root.thickness // 桁が足りない場合にゼロを暗くするか消すロジック(オプション) opacity: (power > 0 && Math.pow(10, power) > Math.abs(root.reading) && index < root.digits - root.decimalPlaces - 1) ? 0.2 : 1.0 } } }