gpt4 book ai didi

c++ - 使用动画变换/旋转 QGraphicsItem Qt,C++

转载 作者:太空宇宙 更新时间:2023-11-04 04:22:57 25 4
gpt4 key购买 nike

目前,我尝试在他的Qt::YAxis处为QGraphicsItem设置动画。我这里有这个示例代码,但它不起作用,因为 QGraphicsPixmapItem 没有属性“transform”。

QPropertyAnimation *animation = new QPropertyAnimation(myQGraphPixItem, "transform");
animation->setDuration(10000);
animation->setStartValue(QTransform::rotate (0, Qt::YAxis));
animation->setEndValue(QTransform::rotate (60, Qt::YAxis));

animation->start();

那么我该如何做到这一点?

最佳答案

声明您拥有变换属性

class YourItem : public QGraphicsPixmapItem
{
Q_OBJECT
Q_PROPERTY(QTransform transfrom READ transform WRITE setTransform)
...
};

关于c++ - 使用动画变换/旋转 QGraphicsItem Qt,C++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11607639/

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