项目需要,要求传入x,y坐标,绘制动图。
想问问大家有什么解决方法吗,刚开始学QT,觉得animation比timer的方法好操作。
//传入一个数组positionList,用get_x_position()方法获取x坐标,y坐标同理
double duration = Time_sec*1000;
QPropertyAnimation *animation = new QPropertyAnimation(picLabel,"geometry");
animation->setKeyValueAt(0, QRect(0,0, 100, 30));
animation->setDuration(duration);
for (int i = 0 ;i < listLength ; i++)
{
animation->setKeyValueAt(1.0*(i+1)/listLength, QRect(positionList[i].get_x_position(), positionList[i].get_y_position(), 100, 30));
path.lineTo(positionList[i].get_x_position(), positionList[i].get_y_position());
}
animation->start();
以上是我的想法,主要问题出在QT绘图是多线程运行的,并不能把路径都读进去再绘制。。