XAnimator QML Type
O tipo XAnimator anima a posição x de um Item. Mais...
| Import Statement: | import QtQuick |
| Inherits: |
Descrição detalhada
Animator Os tipos são diferentes dos tipos normais de animação. Ao usar um Animator, a animação pode ser executada na thread de renderização e o valor da propriedade saltará para o final quando a animação for concluída.
O valor de ` Item::x ` é atualizado após o término da animação.
O trecho de código a seguir mostra como usar um XAnimator junto com um item Rectangle.
Rectangle {
id: xmovingBox
width: 50
height: 50
color: "lightsteelblue"
XAnimator {
target: xmovingBox;
from: 10;
to: 0;
duration: 1000
running: true
}
}Também é possível usar a palavra-chave ` on ` para vincular o `XAnimator` diretamente a uma instância de `Item`.
Rectangle {
width: 50
height: 50
color: "lightsteelblue"
XAnimator on x {
from: 10;
to: 0;
duration: 1000
}
}Observação: os tiposde Animator não oferecem vantagens quando se utiliza um loop de renderização sem threads.
Observação: Recomenda-se que os aplicativos adotem projetos baseados em princípios multithread e assíncronos, em vez de depender de Animators para exibir conteúdo animado enquanto realizam tarefas pesadas e bloqueantes na thread principal (GUI). Em vez de operações longas e bloqueantes, prefira usar ` WorkerScript ` e ` asynchronous image loading ` no QML, além de threads de trabalho, algoritmos paralelos Qt Concurrente corrotinas em C++, mantendo assim todo o aplicativo e a interface do usuário responsivos o tempo todo.
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.