qmlで7セグメント表示
差分
このページの2つのバージョン間の差分を表示します。
| qmlで7セグメント表示 [2026/03/03 02:11] – 作成 araki | qmlで7セグメント表示 [2026/03/03 07:57] (現在) – araki | ||
|---|---|---|---|
| 行 168: | 行 168: | ||
| </ | </ | ||
| + | <file qml TitleBar.qml> | ||
| + | TitleBar { | ||
| + | id: root | ||
| + | |||
| + | property string text: " | ||
| + | property string font: "Noto Serif JP" | ||
| + | property string fontSize: 24 | ||
| + | property string backgroundColor: | ||
| + | property string foregroundColor: | ||
| + | Item { | ||
| + | Rectangle { | ||
| + | anchors.fill: | ||
| + | gradient: | ||
| + | orientation: | ||
| + | GradientStop { position: 0.0; color: "# | ||
| + | GradientStop { position: 0.5; color: "# | ||
| + | GradientStop { position: 1.0; color: "# | ||
| + | } | ||
| + | padding: 0 | ||
| + | Canvas { | ||
| + | id: canvas | ||
| + | anchors.fill: | ||
| + | property real labelHeight: | ||
| + | property real labelWidth: label.contentWidth | ||
| + | |||
| + | onPaint: | ||
| + | var ctx = getContext(" | ||
| + | ctx.reset() | ||
| + | ctx.clearRect(0, | ||
| + | ctx.beginPath() | ||
| + | ctx.moveTo(0, | ||
| + | ctx.lineTo(labelWidth + 20, 0) | ||
| + | ctx.lineTo(labelWidth + 20 + height / 4, height / 2) | ||
| + | ctx.lineTo(width - 1, height / 2) | ||
| + | ctx.lineTo(width - 1, height - 1) | ||
| + | ctx.lineTo(0, | ||
| + | ctx.closePath() | ||
| + | ctx.fillStyle = "# | ||
| + | ctx.fill() | ||
| + | } | ||
| + | |||
| + | Text { | ||
| + | id: label | ||
| + | text: root.text | ||
| + | color: root.foregroundColor | ||
| + | font.family: | ||
| + | font.pixelSize: | ||
| + | horizontalAlignment: | ||
| + | verticalAlignment: | ||
| + | padding: | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | </ | ||
qmlで7セグメント表示.txt · 最終更新: by araki
