QGraphicsItemAnimation Class
QGraphicsItemAnimation 클래스는 QGraphicsItem 에 대한 간단한 애니메이션 기능을 제공합니다. 더 보기...
| 헤더: | #include <QGraphicsItemAnimation> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Widgets) target_link_libraries(mytarget PRIVATE Qt6::Widgets) |
| qmake: | QT += widgets |
| 상속: | QObject |
| 상태: | 사용 중단됨 |
이 클래스는 더 이상 사용되지 않습니다. 새로운 코드에서는 이 클래스를 사용하지 말 것을 강력히 권장합니다.
공개 함수
| QGraphicsItemAnimation(QObject *parent = nullptr) | |
| virtual | ~QGraphicsItemAnimation() |
| void | clear() |
| qreal | horizontalScaleAt(qreal step) const |
| qreal | horizontalShearAt(qreal step) const |
| QGraphicsItem * | item() const |
| QPointF | posAt(qreal step) const |
| QList<std::pair<qreal, QPointF>> | posList() const |
| qreal | rotationAt(qreal step) const |
| QList<std::pair<qreal, qreal>> | rotationList() const |
| QList<std::pair<qreal, QPointF>> | scaleList() const |
| void | setItem(QGraphicsItem *item) |
| void | setPosAt(qreal step, const QPointF &point) |
| void | setRotationAt(qreal step, qreal angle) |
| void | setScaleAt(qreal step, qreal sx, qreal sy) |
| void | setShearAt(qreal step, qreal sh, qreal sv) |
| void | setTimeLine(QTimeLine *timeLine) |
| void | setTranslationAt(qreal step, qreal dx, qreal dy) |
| QList<std::pair<qreal, QPointF>> | shearList() const |
| QTimeLine * | timeLine() const |
| QTransform | transformAt(qreal step) const |
| QList<std::pair<qreal, QPointF>> | translationList() const |
| qreal | verticalScaleAt(qreal step) const |
| qreal | verticalShearAt(qreal step) const |
| qreal | xTranslationAt(qreal step) const |
| qreal | yTranslationAt(qreal step) const |
공개 슬롯
| void | setStep(qreal step) |
보호된 함수
| virtual void | afterAnimationStep(qreal step) |
| virtual void | beforeAnimationStep(qreal step) |
상세 설명
QGraphicsItemAnimation 클래스는 QGraphicsItem QGraphicsItem 에 애니메이션을 적용합니다. 지정된 단계마다 항목의 변환 행렬에 대한 변경 사항을 예약할 수 있습니다. QGraphicsItemAnimation 클래스에는 현재 단계 값이 있습니다. 이 값이 변경되면 해당 단계에서 예약된 변환이 수행됩니다. 애니메이션의 현재 단계는 ` setStep() ` 함수를 사용하여 설정됩니다.
QGraphicsItemAnimation은 행렬을 계산하기 위해 가장 가까운 인접한 예정된 변경 사항들 사이에서 간단한 선형 보간을 수행합니다. 예를 들어, 항목의 위치를 0.0과 1.0으로 설정하면, 애니메이션은 해당 위치들 사이를 직선으로 이동하는 항목의 모습을 보여줍니다. 크기 조정 및 회전도 마찬가지입니다.
일반적으로 이 클래스는 타임라인( QTimeLine)과 함께 사용됩니다. 이때 타임라인의 ` valueChanged()` 신호를 ` setStep() ` 슬롯에 연결합니다. 예를 들어, 다양한 단계 값에 대해 ` setRotationAt() `를 호출하여 항목의 회전을 설정할 수 있습니다. 애니메이션의 타임라인은 ` setTimeLine()` 함수를 사용하여 설정됩니다.
다음은 타임라인이 포함된 애니메이션 예시입니다:
QGraphicsItem *ball = new QGraphicsEllipseItem(0, 0, 20, 20);
QTimeLine *timer = new QTimeLine(5000);
timer->setFrameRange(0, 100);
QGraphicsItemAnimation *animation = new QGraphicsItemAnimation;
animation->setItem(ball);
animation->setTimeLine(timer);
for (int i = 0; i < 200; ++i)
animation->setPosAt(i / 200.0, QPointF(i, i));
QGraphicsScene *scene = new QGraphicsScene;
scene->setSceneRect(0, 0, 250, 250);
scene->addItem(ball);
QGraphicsView *view = new QGraphicsView(scene);
view->show();
timer->start();단, 단계(step) 값은 0.0과 1.0 사이여야 합니다. setUpdateInterval()를 사용해야 할 수도 있습니다. 기본 업데이트 간격은 40ms입니다. 예약된 변환은 일단 설정되면 제거할 수 없으므로, 동일한 단계에서 동일한 종류의 변환(예: 회전)을 여러 개 예약하는 것은 권장하지 않습니다.
QTimeLine 및 그래픽스 뷰 프레임워크도 참조하십시오 .
멤버 함수 설명서
QGraphicsItemAnimation::QGraphicsItemAnimation(QObject *parent = nullptr)
지정된 ` parent`를 사용하여 애니메이션 객체를 생성합니다.
[virtual noexcept] QGraphicsItemAnimation::~QGraphicsItemAnimation()
애니메이션 객체를 삭제합니다.
[virtual protected] void QGraphicsItemAnimation::afterAnimationStep(qreal step)
이 메서드는 새로운 단계가 진행된 후 추가 코드를 실행해야 하는 하위 클래스에서 재정의하도록 설계되었습니다. 애니메이션 ` step `은 해당 애니메이션의 값에 따라 동작이 달라지는 경우에 사용할 수 있도록 제공됩니다.
[virtual protected] void QGraphicsItemAnimation::beforeAnimationStep(qreal step)
이 메서드는 새로운 단계가 시작되기 전에 추가 코드를 실행해야 하는 하위 클래스에서 재정의하도록 설계되었습니다. 애니메이션 step 는 해당 애니메이션의 값에 따라 동작이 달라지는 경우에 사용할 수 있도록 제공됩니다.
void QGraphicsItemAnimation::clear()
애니메이션에 사용된 예약된 변환을 삭제하지만, 아이템과 타임라인은 유지합니다.
qreal QGraphicsItemAnimation::horizontalScaleAt(qreal step) const
지정된 step 값에 해당하는 항목의 가로 스케일을 반환합니다.
setScaleAt()도 참조하십시오 .
qreal QGraphicsItemAnimation::horizontalShearAt(qreal step) const
지정된 ` step ` 값에 해당하는 항목의 수평 전단량을 반환합니다.
setShearAt()도 참조하십시오 .
QGraphicsItem *QGraphicsItemAnimation::item() const
애니메이션 객체가 적용되는 항목을 반환합니다.
setItem()도 참조하십시오 .
QPointF QGraphicsItemAnimation::posAt(qreal step) const
지정된 ` step ` 값에 해당하는 항목의 위치를 반환합니다.
setPosAt()도 참조하십시오 .
QList<std::pair<qreal, QPointF>> QGraphicsItemAnimation::posList() const
명시적으로 삽입된 모든 위치를 반환합니다.
posAt() 및 setPosAt()도 참조하십시오 .
qreal QGraphicsItemAnimation::rotationAt(qreal step) const
지정된 ` step ` 값에서 항목이 회전된 각도를 반환합니다.
setRotationAt()도 참조하십시오 .
QList<std::pair<qreal, qreal>> QGraphicsItemAnimation::rotationList() const
명시적으로 삽입된 모든 회전 정보를 반환합니다.
rotationAt() 및 setRotationAt()도 참조하십시오 .
QList<std::pair<qreal, QPointF>> QGraphicsItemAnimation::scaleList() const
명시적으로 삽입된 모든 스케일을 반환합니다.
verticalScaleAt(), horizontalScaleAt() 및 setScaleAt()도 참조하십시오 .
void QGraphicsItemAnimation::setItem(QGraphicsItem *item)
지정된 ‘ item ’를 애니메이션에 사용하도록 설정합니다.
item()도 참조하십시오 .
void QGraphicsItemAnimation::setPosAt(qreal step, const QPointF &point)
지정된 ` step ` 값에 해당하는 항목의 위치를 ` point `로 설정합니다.
posAt()도 참조하십시오 .
void QGraphicsItemAnimation::setRotationAt(qreal step, qreal angle)
지정된 step 값에 해당하는 항목의 회전을 angle 에 명시된 대로 설정합니다.
rotationAt()도 참조하십시오 .
void QGraphicsItemAnimation::setScaleAt(qreal step, qreal sx, qreal sy)
sx 및 sy 에서 지정한 수평 및 수직 배율 계수를 사용하여, 지정된 step 값에 따라 항목의 배율을 설정합니다.
verticalScaleAt() 및 horizontalScaleAt()도 참조하십시오 .
void QGraphicsItemAnimation::setShearAt(qreal step, qreal sh, qreal sv)
sh 및 sv 에서 지정한 수평 및 수직 전단 계수를 사용하여, 지정된 step 값에 따라 항목의 전단 변형을 설정합니다.
verticalShearAt() 및 horizontalShearAt()도 참조하십시오 .
[slot] void QGraphicsItemAnimation::setStep(qreal step)
애니메이션의 현재 ‘ step ’ 값을 설정하여, 이 단계에서 예약된 변환이 수행되도록 합니다.
void QGraphicsItemAnimation::setTimeLine(QTimeLine *timeLine)
애니메이션 속도를 제어하는 데 사용되는 타임라인 객체를 지정된 timeLine 로 설정합니다.
timeLine()도 참조하십시오 .
void QGraphicsItemAnimation::setTranslationAt(qreal step, qreal dx, qreal dy)
dx 및 dy 에서 지정한 수평 및 수직 좌표를 사용하여, 지정된 step 값에 따라 항목의 변위(translation)를 설정합니다.
xTranslationAt() 및 yTranslationAt()도 참조하십시오 .
QList<std::pair<qreal, QPointF>> QGraphicsItemAnimation::shearList() const
명시적으로 삽입된 모든 전단 변형을 반환합니다.
verticalShearAt(), horizontalShearAt() 및 setShearAt()도 참조하십시오 .
QTimeLine *QGraphicsItemAnimation::timeLine() const
애니메이션이 진행되는 속도를 제어하는 데 사용되는 타임라인 객체를 반환합니다.
setTimeLine()도 참조하십시오 .
QTransform QGraphicsItemAnimation::transformAt(qreal step) const
지정된 ` step ` 값에 해당하는 항목에 적용된 변환을 반환합니다.
QList<std::pair<qreal, QPointF>> QGraphicsItemAnimation::translationList() const
명시적으로 삽입된 모든 번역 내용을 반환합니다.
xTranslationAt(), yTranslationAt(), setTranslationAt()도 참조하십시오 .
qreal QGraphicsItemAnimation::verticalScaleAt(qreal step) const
지정된 ` step ` 값에 해당하는 항목의 수직 스케일을 반환합니다.
setScaleAt()도 참조하십시오 .
qreal QGraphicsItemAnimation::verticalShearAt(qreal step) const
지정된 step 값에 해당하는 항목의 수직 전단을 반환합니다.
setShearAt()도 참조하십시오 .
qreal QGraphicsItemAnimation::xTranslationAt(qreal step) const
지정된 step 값에 해당하는 항목의 수평 변위량을 반환합니다.
setTranslationAt()도 참조하십시오 .
qreal QGraphicsItemAnimation::yTranslationAt(qreal step) const
지정된 step 값에 해당하는 항목의 수직 변위량을 반환합니다.
setTranslationAt()도 참조하십시오 .
© 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.