gpt4 book ai didi

c++ - Qt - 跟踪 QAbstractAnimation 运动

转载 作者:行者123 更新时间:2023-12-01 14:48:00 26 4
gpt4 key购买 nike

我在屏幕上有一个移动的圆圈。它是在一个类中声明的,它具有三个属性:中心、半径X 和半径Y。
我有以下代码:

m_ellipse.setVisible(true);
m_ellipse.setCenter(QPoint(30, 30));
m_ellipse.setRadiusX(40);
m_ellipse.setRadiusY(40);


QPropertyAnimation *animationCenter = new QPropertyAnimation(&m_ellipse, "center", this);
animationCenter->setStartValue(QPoint(30, 30));
animationCenter->setEndValue(QPoint(460, 540));
animationCenter->setDuration(3400);
animationCenter->start();

有没有办法在动画过程中获取当前位置或更改基本中心?

最佳答案

一种可能的解决方案是使用 valueChanged 信号:

QObject::connect(animationCenter, &QPropertyAnimation::valueChanged, [](const QVariant &value){
QPoint p = value.toPoint();
qDebug() << p;
});

关于c++ - Qt - 跟踪 QAbstractAnimation 运动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61508372/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com