QGraphicsItemAnimation Class

QGraphicsItemAnimation 클래스는 QGraphicsItem 에 대한 간단한 애니메이션 지원을 제공합니다. 더 보기...

Header: #include <QGraphicsItemAnimation>
CMake: find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(mytarget PRIVATE Qt6::Widgets)
qmake: QT += widgets
상속합니다: QObject
상태: Deprecated

이 클래스는 더 이상 사용되지 않습니다. 새 코드에서 사용하지 않는 것이 좋습니다.

공용 함수

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. 지정된 단계에서 항목의 변환 매트릭스를 변경하도록 예약할 수 있습니다. 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();

단계는 0.0에서 1.0 사이입니다. setUpdateInterval ()를 사용해야 할 수도 있습니다. 기본 업데이트 간격은 40밀리초입니다. 예약된 변환은 한 번 설정하면 제거할 수 없으므로 같은 종류의 변환(예: 회전)을 같은 단계에서 여러 개 예약하는 것은 권장하지 않습니다.

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)

sxsy 에서 지정한 가로 및 세로 배율을 사용하여 지정된 step 값으로 항목의 배율을 설정합니다.

verticalScaleAt() 및 horizontalScaleAt()도 참조하세요 .

void QGraphicsItemAnimation::setShearAt(qreal step, qreal sh, qreal sv)

shsv 에서 지정한 수평 및 수직 전단 계수를 사용하여 항목의 전단을 지정된 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)

dxdy 에서 지정한 가로 및 세로 좌표를 사용하여 지정된 step 값으로 항목의 번역을 설정합니다.

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()도 참조하세요 .

© 2025 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.