Как правильно разместить и анимировать изображение в QML?C++

Программы на C++. Форум разработчиков
Ответить
Anonymous
 Как правильно разместить и анимировать изображение в QML?

Сообщение Anonymous »

Я начал изучать Qt и QML с простого (и ужасного :D) проекта интерфейса автомобильного кластерного инструмента. Ниже вы можете найти код моего QML-интерфейса:

Код: Выделить всё

// CircularGauge.qml

import QtQuick 2.15
import QtQuick.Controls 2.15

Item {
id: root
property real value: 0
property real maxValue: 100
property real minValue: 0
property real step: 10
property real startAngle: -135
property real endAngle: 135

width: 400
height: 400

Canvas {
id: canvas
anchors.centerIn: parent
width: 300
height: 300

onPaint: {
var ctx = getContext("2d");
ctx.clearRect(0, 0, width, height);

var centerX = width / 2;
var centerY = height / 2;
var radius = 140;
var startRad = root.startAngle * Math.PI / 180;
var endRad = root.endAngle * Math.PI / 180;

// Draw translucent background
ctx.beginPath();
ctx.arc(centerX, centerY, radius, 0, Math.PI * 2);
ctx.fillStyle = "rgba(30, 30, 30, 0.8)";
ctx.fill();

// Outer gradient ring
var gradient = ctx.createLinearGradient(0, 0, width, height);
gradient.addColorStop(0, "#3f51b5");
gradient.addColorStop(1, "#2196f3");

ctx.beginPath();
ctx.arc(centerX, centerY, radius, startRad, endRad);
ctx.lineWidth = 20;
ctx.strokeStyle = gradient;
ctx.stroke();

// Draw notches and values
for (var i = root.minValue; i 

Подробнее здесь: [url]https://stackoverflow.com/questions/79309624/how-to-correctly-place-and-animate-image-on-qml[/url]
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»